mysql - Select 1 row from table where foreign key table records exist -


i've got 2 tables, products , productimages 1 many relationship between products , productimages. i'm trying work query on on products table condition results contain rows matching records in productimages table.

products ---------- id (pk)  productimages --------------- id (pk) product_id (fk products) 

the way can work subquery, surely there must better/more efficient way.

select p.* products p inner join productimages pi on p.id = pi.product_id group p.id 

Comments

Popular posts from this blog

All overlapping substrings matching a java regex -

c++ - Using OpenSSL in a multi-threaded application -

php - Deleting/Renaming a locked file -