sfx Posted November 1, 2004 Report 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?
bubu Posted November 1, 2004 Report 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
рпр Posted November 1, 2004 Report 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;
sfx Posted November 1, 2004 Author Report 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!
Venom Posted November 2, 2004 Report Posted November 2, 2004 select * from tabula1 LEFT/RIGHT JOIN ON tabula1.id=tabula2.id WHERE tabula1.no=1 order by tabula1.id; ?
bubu Posted November 2, 2004 Report Posted November 2, 2004 Ak tur ir divas dažādas tabulas, nepamanīju. :) Iedod piemēru ar datiem, kas ir tajās.
sfx Posted November 2, 2004 Author Report 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???
bubu Posted November 2, 2004 Report 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ļā ;)
Recommended Posts