Pogledajte određenu poruku
Staro 09. 06. 2011.   #18
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default

JOIN...

PHP kôd:
SELECT t1.rastojanjet2.grad AS grad_1t3.grad AS grad_2
FROM tabela2 
AS t1
LEFT JOIN tabela1 
AS t2 ON t1.grad_id1 t2.id
LEFT JOIN tabela1 
AS t3 ON t1.grad_id2 t3.id 
Subselect...
PHP kôd:
SELECT tabela2.rastojanje,
(
SELECT tabela1.grad FROM tabela1 WHERE tabela1.id tabela2.grad_id1) AS grad_1,
(
SELECT tabela1.grad FROM tabela1 WHERE tabela1.id tabela2.grad_id2) AS grad_2
FROM tabela2

Koristi JOIN jer je dosta brži...

Poslednja izmena od webarto : 09. 06. 2011. u 14:51.
webarto je offline   Odgovorite uz citat