1

I've got a mysql database containing table "numbers" and entries

id | numberss
1 | 1,5,45
2 | 11,8,99
3 | 14, 15,84
4 | 1,58,47

How I have to write a mysql query, to retreive info only from those tables, which got number "1" in field "numberss" ? Not 11, not 15, only 1. Now I have:

mysql_query("SELECT * FROM numbers WHERE numberss LIKE '%1%'"); 

But of course it doesn't work how I want to...

2 Answers 2

3
SELECT * FROM numbers WHERE FIND_IN_SET(1, numberss);
Sign up to request clarification or add additional context in comments.

Comments

0
SELECT * FROM numberss WHERE numberss 
LIKE  '%[^0-9]1[^0-9]%' 
or numberss like '1[^0-9]%'  
or numberss like '%[^0-9]1'

should work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.