I’ve got a problem with SELECTing stuff from a MySQL database based on a specific character in a specific column. This column contains a string with 1s and 0s. Example string:
0101000000.
I need to SELECT only the rows which look something like this (X is wildcard): X1X1X0XXXX
How do I do this with a SELECT query? I’m sure it isn’t that hard.
Sincerly,
Axel Latvala
If this col is a string then you should be able to match rows with:
if it’s just 0 and 1 that you’re storing (it’s binary) then you should probably cast it to an
INTand use bit masks to query the table. This method would use far less storage space and be far faster, it’d be more complicated to implement though.MySQL’s pattern matching doc: http://dev.mysql.com/doc/refman/5.1/en/pattern-matching.html