1
I have a database with the tables estabelecimentos
and produtos
. Register the products relating to the establishments.
I need to make a query where select only one product from each establishment, I thought to do with LIMIT but it seems to me that it will not work.
Example: if I have 10 stores and 100 products, I want a consultation that returns me 10 products but being one of each establishment.
Add the schema of your tables to the question to facilitate the answer.
– user28595
I added, if you have any more questions just speak. Thank you
– Murilo Souza
I think it works with
LIMIT
, can put in afor
indicating the establishment id (or do manual) and searchingSELECT * FROM produto WHERE ID_estab = $cont-or-id LIMIT 1
– Leonardo