sfx Posted November 1, 2004 Report Share Posted November 1, 2004 Hai! kaa sho uzraksta ar vienu QUERY??? query = Select * from table_1 where no=1 query = Select * from table_2 order by ID Varbuut ir kaadi citi varianti? Link to comment Share on other sites More sharing options...
bubu Posted November 1, 2004 Report Share Posted November 1, 2004 Ja tev vajag abu selektu rezultātu apvienojumu tad: SELECT * FROM table_1 WHERE no=1 UNION SELECT * FROM table_2 ORDER BY id Ja vajag tos ierakstus, kuriem no=1 un sakārtotus pēc id, tad: SELECT * FROM table_1 WHERE no=1 ORDER BY id Link to comment Share on other sites More sharing options...
рпр Posted November 1, 2004 Report Share Posted November 1, 2004 ja ir taas saites kaa vinjas tur sauc... select * from tabula1,tabula2 where tabula1.id=tabula2.id and tabula1.no=1 order by tabula1.id; Link to comment Share on other sites More sharing options...
sfx Posted November 1, 2004 Author Report Share Posted November 1, 2004 Hmm, interesanti! Bet kad es gribu drukaat kaadu ierakstu piemeeram no tabulas2 tad shie ieraksti ir reizinaas ar tabulas1 kopeejo ierakstu skaitu! Tad kaa drukaat pareizi aaraaa no shaada Query? Ja shaadi to dara: $result = mysql_query($query); while($row=mysql_fetch_row($result)){ pirin($row[1]); } tad tur medzeklis kautkaads sanaak! Link to comment Share on other sites More sharing options...
Venom Posted November 2, 2004 Report Share Posted November 2, 2004 select * from tabula1 LEFT/RIGHT JOIN ON tabula1.id=tabula2.id WHERE tabula1.no=1 order by tabula1.id; ? Link to comment Share on other sites More sharing options...
bubu Posted November 2, 2004 Report Share Posted November 2, 2004 Ak tur ir divas dažādas tabulas, nepamanīju. :) Iedod piemēru ar datiem, kas ir tajās. Link to comment Share on other sites More sharing options...
sfx Posted November 2, 2004 Author Report Share Posted November 2, 2004 Tab1: ID | NOSAUKUMS | SEL Tab2: IDD | Tab1ID | BILDE | TXT man vajag lai dod rezultu Tab1ID ( no Tab2) kur SEL=1 (no Tab1). Saprati domu??? Link to comment Share on other sites More sharing options...
bubu Posted November 2, 2004 Report Share Posted November 2, 2004 Nu tak visprimitīvākais joins (1:n attiecība tak): SELECT * FROM Tab1, Tab2 WHERE Tab1.ID = Tab2.Tab1ID AND Tab1.No=1 ORDER BY Tab1.ID Nākamreiz šitādus jautājumus neliec PHP sadaļā, bet Datubāžu sadaļā ;) Link to comment Share on other sites More sharing options...
Recommended Posts