MySQL Forums
Forum List  »  Italian

query su 2 o più tabelle che non hanno sempre record relazionati
Posted by: Claudio Z
Date: May 13, 2011 03:59AM

Buongiorno a tutti,

Ho un problema con una query su 2 o più tabelle relazionate, devo estrarre i i record che hanno almeno una corrispondenza in una delle tabelle.

TB a1: id, txt
TB b2: id, id_a1, txt
TB c3: id, id_a1, txt

La query sarebbe questa:
SELECT a.id FROM a1 a, b2 b, c3 c, WHERE b.id_a1=a.id AND c.id_a1=a.id AND (a.txt LIKE '%key%' OR b.txt LIKE '%key%' OR c.txt LIKE '%key%')

Il problema è che le tabelle b2 e c3 possono NON avere dei record relazionati con la TB a1 e quindi anche se in una delle altre è presente la mia key non avrei risultati.

Come devo scrivere la query perchè mi renda i risultati anche in assenza di record relazionati nelle altre 2 TB ?

Grazie mille
Buona giornata
Claudio

Options: ReplyQuote


Subject
Views
Written By
Posted
query su 2 o più tabelle che non hanno sempre record relazionati
2656
May 13, 2011 03:59AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.