MySQL Bit comparison (days of week)

This has surely got to be an easy thing to accomplish.

I want to compare two bit strings (in this case representing days of the week) to see if they match, e.g.
1111000 AND 0000100 = 0
1111100 AND 0000100 = 1
The output should be 1 or 0

When I try this in MySQL
SELECT 1111000 AND 0000100 seems to give 1
SELECT 1111000 & 0000100 gives an integer output.

How do I do it?
Stuart LandrethAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Maybe you're not specifying the data correctly.
SELECT b'1111000' & b'0000100'

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bitwise AND of 1111000 and 0000100 is 0, but bitwise AND of 1111100 and 0000100 is 0000100 which has a decimal value of 4. If you just want to compare two strings, you could use strcmp ( which "returns 0 if the strings are the same, -1 if the first argument is smaller than the second according to the current sort order, and 1 otherwise."
Stuart LandrethAuthor Commented:
SELECT b'1111000' & b'0000100' > 0 gives the exact answer but this is the closest solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.