php - Getting two or more images ids from the same column -
i got mysql table 1 or more comma separated numbers in it. numbers refer id's in mysql table, witch includes name of image.
i want select row field "images" contains "1,43" , display 2 images id 1 , 43 2nd table.
do have have 2 numbers in differents fields? i'd prefer keep them in same one.
use find_in_set
. assuming have table below,
table1
+++++++++++ images +++++++++++ 1,43
table2
+++++++++++++++++ imageid image +++++++++++++++++ 1 .... 43 ....
sample query:
select b.* table1 inner join table2 b on find_in_set(b.imageid, a.images) > 0
if have time modify structure of table. please do. query above perform slow if doing on large databases.
Comments
Post a Comment