Using a where clause with a sequence of IDs
A leading and an ending can be added to the value field in the DB ,
.
eg.
Edit
1,2,3,4,5
to
,1,2,3,4,5,
So that each Id has a leading and trailing comma ,
Now update the body of the function:
function($id){
$sql = "select * from content_noti
where users_id LIKE '%,$id,%'"
}
In this case, you don't have any error, as if you were looking for a user id 1
, then you will only get 1
, not 11
either 111
or 1343
.
source to share
SELECT * from content_noti where users_id = "1" OR users_id = LIKE '%1,%' OR users_id = LIKE '%,1%'
Storing multiple chunks of data as a separate comma separated column is really bad design for databases, and if at all possible, you should look into normalizing it by creating a join table and joining it.
The performance of the above query will be terrible and difficult to maintain.
source to share