问题
this is my database:
I would retrieve all records in richiestepreventivo where idImpresa==xx and all the data in privati where privati.id==richiestepreventivo.idPrivato. Can you explain me how I have to set the query with join?
Thanks.
回答1:
SELECT *
FROM privati AS p
INNER JOIN richiestepreventivo AS r
ON p.id = r.idPrivato
WHERE r.idImpresa = xx
Are you asking for a simple inner join
回答2:
SELECT r.id, p.data
FROM richiestepreventivo r
JOIN privati p ON p.id = r.idPrivato
WHERE r.id = XX;
来源:https://stackoverflow.com/questions/7026828/mysql-query-with-join