Mysql
 sql >> Database >  >> RDS >> Mysql

Query di tre tabelle unite con relazione molti-a-molti in JPA

Penso che il tuo SQL potrebbe assomigliare a questo:

SELECT * FROM Hospital WHERE Postcode = 3000 AND
Hospital_id IN
    (SELECT Hospital_id FROM Hospital_Medical hm
    INNER JOIN Medical_Service m ON hm.Medical_id = m.Medical_id
    where Medical_name = 'Emergency') AND
Hospital_id IN
(SELECT Hospital_id FROM Hospital_Language hl
    INNER JOIN Language_Service l ON hl.Language_id = l.Language_id
    where Language_name = 'English')