[MySQL] wybieranie danych z 2 z 3 tabel, w zależności od z

0

mam pewien problem:

mam 3 tabele:

a (id, 2ndid, type)
b (id2, name)
c (id3, 2nd_name)

otóż chcę w zależności od zawartości a.type (0 = b, 1 = c) wybierać dane z tabeli b lub c.
próbowałem na wiele sposobów, ale żaden nie chciał działać...

0

a probowales:

$res=mysql_query("SELECT type FROM a");
$type=mysql_fetch_array($res);
mysql_free_result($res);
if($type["type"]==0) {
$res=mysql_query("SELECT * FROM b");
$dane=mysql_fetch_array($res);
mysql_free_result($res);
} else if($type["type"]==1 {
$res=mysql_query("SELECT * FROM c");
$dane=mysql_fetch_array($res);
mysql_free_result($res);
}

??

0
a (id, 2ndid, type)
b (id2, type, name)

i tabela c zbedna

SELECT * FROM a,b WHERE a.type=b.type

bardziej optymalne rozwiazanie

0

no nic to też się przyda... zapomniałem uwzględnić, że w tabelach b i c są inne pola... :O

1 użytkowników online, w tym zalogowanych: 0, gości: 1