Reputation: 133
I have created a mail table where i have the following fields.
id mail_to mail_subject mail_message
1 6,9,10 Test Mail Test Message
2 4,8,6 Test Mail Test Message
Values stored in mail_to field are id of users. I want to display all the mail where mail_to is 6. How to use the where condition in this case.
I tried to achieve the result with this query but it did not work.
SELECT * FROM tbl_profile_inbox WHERE mail_to = '6' ;
Can you guys help on this one.
Upvotes: 2
Views: 386
Reputation: 1667
you can use REGEXP
also.
SELECT * FROM tbl_profile_inbox WHERE mail_ to REGEXP '[[:<:]]6[[:>:]]'
Upvotes: 0
Reputation: 5316
You can use FIND_IN_SET()
for that:
SELECT * FROM tbl_profile_inbox WHERE FIND_IN_SET('6',mail_to)
Upvotes: 3