Dooling Posted August 22, 2007 Report Share Posted August 22, 2007 Ir tabula 'atbildes' vid | aid | lauka_mid | atbilde | * 102| 94 | 12 | Diāna | * 103| 94 | 13 | Laila | * 104| 94 | 14 | Karīna | * 105| 97 | 12 | Olga | * 106| 97 | 13 | Lilita | * .... Es esmu izveidojis meklēšanu, bet lieta, ka man neatlasa pareizos ierakstus. Teiksim meklētājam norādu, ka meklē pēc lauka (lauka_id) 12 atbildi (atbilde) Diāna un pēc lauka (lauka_id) 13 atbildi (atbilde) Laila pie tam ņemot vērā, ka aid jābūt vienādam ar 94. Kāds būtu pareizs vaicājums, lai atlasītu pareizi? Mokos jau 3 h un apstājies esmu uz vietas. Pašlaik man ir tāds vaicājums: SELECT aid, anketetajs FROM kd_dala WHERE aid = '46' and ((lauka_mid = '12' and atbilde = 'Diāna') and (lauka_mid = '13' and atbilde = 'Laila')) Link to comment Share on other sites More sharing options...
Delfins Posted August 22, 2007 Report Share Posted August 22, 2007 Tu sapīpējies !? padomā, kas tiks meklēts: lauka_mid = '12' and lauka_mid = '13' Link to comment Share on other sites More sharing options...
Dooling Posted August 22, 2007 Author Report Share Posted August 22, 2007 Nē, uznācis prāta aptumsums Link to comment Share on other sites More sharing options...
Delfins Posted August 22, 2007 Report Share Posted August 22, 2007 Tu mēģini dabūt kaut ko līdzīgu: if (2 + 2 == 5) { echo 'Utopia'; } Link to comment Share on other sites More sharing options...
Dooling Posted August 22, 2007 Author Report Share Posted August 22, 2007 Nu bet kā lai panāk man vēlamo rezultātu? Ir kādam idejas? Link to comment Share on other sites More sharing options...
Delfins Posted August 22, 2007 Report Share Posted August 22, 2007 Kā var rakstīt SQL un tai pat laikā nezināt par tādu lietu kā `OR` Link to comment Share on other sites More sharing options...
Dooling Posted August 22, 2007 Author Report Share Posted August 22, 2007 Zinu es tādu lietu 'OR'. Bet man nosacījumam (lauka_mid = '12' and atbilde = 'Diāna') un (lauka_mid = '13' and atbilde = 'Laila')) jāpārbauda ar nosacījumu AND, nevis OR. Link to comment Share on other sites More sharing options...
Aleksejs Posted August 22, 2007 Report Share Posted August 22, 2007 Kurām rindiņām jābūt atlasītām no tevis minētās tabulas? Link to comment Share on other sites More sharing options...
Dooling Posted August 22, 2007 Author Report Share Posted August 22, 2007 Lūk šīm divām: vid | aid | lauka_mid | atbilde | * 102| 94 | 12 | Diāna | * 103| 94 | 13 | Laila | * Link to comment Share on other sites More sharing options...
Aleksejs Posted August 22, 2007 Report Share Posted August 22, 2007 Lūk šīm divām: vid | aid | lauka_mid | atbilde | * 102| 94 | 12 | Diāna | * 103| 94 | 13 | Laila | * WHERE (aid = 94 AND lauka_mid = 12) OR (aid = 94 AND lauka_mid = 13) jeb WHERE aid = 94 AND (lauka_mid = 12 OR lauka_mid = 13) Link to comment Share on other sites More sharing options...
marcis Posted August 23, 2007 Report Share Posted August 23, 2007 WHERE aid='94' AND lauka_mid IN ('12', '13') Link to comment Share on other sites More sharing options...
Recommended Posts