mysql - Query with WHERE / sub query containing multiple records -
this query:
select * img_ref id_img = (select `id_img` img_ref `id_user`=4)
i'm trying select records img_ref id_img = id_img attached specific id_user.
however, subquery contains multiple rows/results , therefore throws error "subquery returns more 1 row". how modify statement "where id_img=" part , subquery allow multiple rows?
thanks in advance.
when using subquery equals, subquery can return single record. use in
return multiple records:
select * img_ref id_img in (select `id_img` img_ref `id_user`=4)
for performance reasons (check post), may want move join
:
select i.* img_ref join img_ref i2 on i.id_img = i2.id_img , i2.id_user=4
Comments
Post a Comment