php - Differentiate MYSQL Query for entries with similar numbers (17, 170, 171) -
i'm working on trying find id's within database. need find following:
17,
,17
,17,
making sure not find other id's start 17 (i.e. 170, 171, 173, etc). i've set following variables pull mysql query:
$userid = '' . $row['userid'] . ',%'; $userid2 = '%,' . $row['userid'] . '%'; $userid3 = '' . $row['userid'] . '%';
but i'm finding i'm pulling in id 170. think happens whenever id 170 put @ end of string. can provide appreciate. here query i'm working with:
"select formid, draft, activestatus forms notifyusers '$userid' , activestatus != '3' or notifyusers '$userid2' , activestatus != '3' or notifyusers '$userid3' , activestatus != '3'";
you use find_in_set function, this:
select formid, draft, activestatus forms (find_in_set('17', notifyusers)>0 , activestatus != '3') or ...
or can use way:
where concat(',', notifyusers, ',') ('%,17,%')
Comments
Post a Comment