dedlfix: MySQL leere Tabelle

Beitrag lesen

SELECT tabelle_a.spalte FROM tabelle_a, tabelle_b WHERE tabelle_a.id="$variable" AND tabelle_b.nr!=tabelle_a.id;

... wenn allerdings Tabelle B keinen EIntrag hat (also leer ist) dann gibt die Abfrage nichts zurück. Ich möchte jedoch in diesem Fall das AND tabelle_b.nr!=tabelle_a.id ignorieren. Gibt es da eine Möglichkeit oder muss ich das über mehrere ABfragen machen?

Geht ...WHERE tabelle_a.id="$variable" AND (tabelle_b.nr!=tabelle_a.id OR tabelle_b.nr IS NULL) ?