Ich habe 3 Tabellen Appliance, Tx_property, Rx_propertyDie Kombination von zwei Abfragen JOIN zusammen
#Appliance Table structure:
-id
-tx_property_id
-rx_property_id
-...
#Tx_property Table structure:
-id
-...
#Rx_property Table structure:
-id
-...
Constraint auf gesetzt rx_property.id = appliance.id und tx_property.id = appliance.id
Ist es möglich, nur eine Abfrage ausführen, um alle Datensätze aus der Appliance-Tabelle abzurufen, die entsprechende Einträge in (basierend auf rx_property_id und tx_property_id) enthalten?
Zusammenfassend möchte ich 2 Abfragen unten in eins kombinieren.
select * from appliance INNER JOIN rx_property ON rx_property.id= appliance.rx_property_id;
select * from appliance INNER JOIN tx_property.id ON tx_property.id= appliance.tx_property_id;
Irgendwelche Ideen? Vielen Dank!
Edit:
Wenn ich also Beispieldatensätze wie unten haben:
appliance records:
id = 70
tx_property_id = 11
rx_property_id = null
id = 71
tx_property_id = 12
rx_property_id = null
id = 72
tx_property_id = null
rx_property_id = 11
id = 73
tx_property_id = null
rx_property_id = 12
tx_property records:
id = 11
name = 'tx_aa'
id = 12
name = 'tx_bb'
rx_property records:
id = 11
name = 'rx_aa'
id = 12
name = 'rx_bb'
Ich will 4 von ihnen abgerufen werden wie:
appliance.id = 70
appliance.tx_property_id = 11
appliance.rx_property_id = null
tx_property.id = 11
tx_property.name = 'tx_aa'
appliance.id = 71
appliance.tx_property_id = 12
appliance.rx_property_id = null
tx_property.id = 12
tx_property.name = 'tx_bb'
appliance.id = 72
appliance.tx_property_id = null
appliance.rx_property_id = 11
tx_property.id = 11
tx_property.name = 'rx_aa'
appliance.id = 73
appliance.tx_property_id = null
appliance.rx_property_id = 12
tx_property.id = 11
tx_property.name = 'rx_aa'
ich dies bereits versucht haben, ich bin immer 0 Zeilen zurückgegeben. Wenn ich obige Abfragen getrennt ausführe, bekomme ich korrekt Zeilen zurückgegeben. – Pawel
Das liegt daran, dass Sie keine Datensätze haben, die alle Anforderungen erfüllen. Also passend zu rx_property_id und tx_property_id in allen verwendeten Tabellen. – cybernetic87
Ich denke, es gab ein Missverständnis. Ich habe die Frage aktualisiert, bitte sehen Sie. – Pawel