[eluser]dudeami0[/eluser]
Havn't tested this query, but something like
case 1:
Code:
SELECT * FROM `tshirt` WHERE `colors` REGEXP '[^0-9]?1[^0-9]?' AND `colors` REGEXP '[^0-9]?3[^0-9]?'
case 2
Code:
SELECT * FROM `tshirt` WHERE `colors` REGEXP '[^0-9]?1[^0-9]?' AND `colors` REGEXP '[^0-9]?2[^0-9]?' AND `colors` REGEXP '[^0-9]?3[^0-9]?' AND `colors` REGEXP '[^0-9]?4[^0-9]?' AND `colors` REGEXP '[^0-9]?5[^0-9]?'
case 3
Code:
SELECT * FROM `tshirt` WHERE `colors` REGEXP '[^0-9]?4[^0-9]?' AND `colors` REGEXP '[^0-9]?5[^0-9]?'
That is just repeating the AND operative alot. You can do just one REGEXP check like:
case 1:
Code:
SELECT * FROM `tshirt` WHERE `colors` REGEXP '[^0-9]?1[^0-9]?.*[^0-9]?3[^0-9]?'
case 2:
Code:
SELECT * FROM `tshirt` WHERE `colors` REGEXP '[^0-9]?1[^0-9]?.*[^0-9]?2[^0-9]?.*[^0-9]?3[^0-9]?.*[^0-9]?4[^0-9]?.*[^0-9]?5[^0-9]?'
case 3:
Code:
SELECT * FROM `tshirt` WHERE `colors` REGEXP '[^0-9]?4[^0-9]?.*[^0-9]?5[^0-9]?'
That should work
I didn't use LIKE because of the fact if you get into a 2+ digit number 20 could cause %2% to match it.
If you need help understanding how it works let me know. Also, there might be better solutions to this that I am not aware of.
EDIT: Updated the SQLs (Added the optional ? after the [^0-9]) and tested on my local MySQL server and it works fine!