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ć...
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ć...
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);
}
??
a (id, 2ndid, type)
b (id2, type, name)
i tabela c zbedna
SELECT * FROM a,b WHERE a.type=b.type
bardziej optymalne rozwiazanie
no nic to też się przyda... zapomniałem uwzględnić, że w tabelach b i c są inne pola... :O