I have a column in table "recipes" called "Products". This is is filled like this:
460,450|50,100|243,500|141,5|457,100|383,211|
ProductID,ProductGrams| is the format.
Now i would like to search for an product with id 243 in the above example. How can i do this?
SELECT * FROM recipes WHERE Products LIKE '%243%'
Will also give me results if theres productgrams that are 243.
How can i do this? Im lost...
Its ok if theres also php for a solution to this.
You could do
SELECT * FROM recipes WHERE Products LIKE '243,%' OR Products LIKE '%|243,%
But more importantly this data should be normalized in the database prior to being queried.
只需按自己的喜好包含分隔符,
SELECT * FROM recipes WHERE Products LIKE '%|243,%'
Maybe tthis will work?
SELECT * FROM recipes WHERE Products LIKE '%243,%'
Note the comma.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.