php - Show other rows in MySQL table where a rows have a string with comma matched with a id
one text
I have a table called leads, and the other table is users. Now when the lead is consumed by the user, the field 'consumed_user_id' in leads adds the user_ids with comma delimiter in this field like (21,22,23,24). and other field is hide_seller_id, which adds the user id who want to hide the leads like this.
_______________________________________
| consumed_user_id | hide_seller_id |
| 21,22,23,24 | NULL |
| NULL | 21,22,23 |
_______________________________________
Now both cant be filled, because row1 is consumed one by the user, its already hide, and row2 is hide by users but not consumed. so if user 21, want to see list, row1 and row2, both is not shown in his lead list.
Now I want to show only those leads which are not consumed by the users and which has id in hide_seller_id row. I try this
SELECT * FROM leads
WHERE status = 'verified'
AND NOT FIND_IN_SET('$user_id',consumed_seller_id) OR consumed_seller_id
IS NULL
AND NOT FIND_IN_SET('$user_id',hide_seller_id) OR hide_seller_id IS NULL
ORDER BY id DESC
SourceThis is working for hide_seller_id but not working for consumed_seller_id, please help.