OverBurner Posted February 19, 2004 Report Share Posted February 19, 2004 ir lauks id , kaa lai paarbauda i taads un taads id ieksh tabulas vai nav? piem ja nav tad chiki briki ir huulii haaii :D nenjemt veeraa peedeejos rindinju Link to comment Share on other sites More sharing options...
Aleksejs Posted February 19, 2004 Report Share Posted February 19, 2004 (edited) $x = 3;//tavaveertiiba $rezultats = mysql_query("SELECT id FROM tabula WHERE id = $x LIMIT 0, 1"); if(mysql_num_rows($rezultats)>0){ //Taatad ir taads id } else { //Taatad nav taads id } Vai arī tu domāji tieši par to, vai tabula satur lauku ar nosaukumu "id" ??? Edited February 19, 2004 by Aleksejs Link to comment Share on other sites More sharing options...
рпр Posted February 20, 2004 Report Share Posted February 20, 2004 var arii izmantot mysql funkciju count(). Link to comment Share on other sites More sharing options...
Aleksejs Posted February 20, 2004 Report Share Posted February 20, 2004 Nedaudz OT, bet vai kāds varētu nokomentēt, kurš variants izpildīsies ātrāk? Es domāju, ka "SELECT .... LIMIT 0, 1", jo vaicājums izpildīsies tikai tik ilgi, līdz atradīs pirmo atbilstošo vērtību. Savukārt "SELECT count(...)..." būs jāiziet cauri visai tabulai. Vai es pareizi domāju? Link to comment Share on other sites More sharing options...
jb4 Posted February 20, 2004 Report Share Posted February 20, 2004 SELECT id FROM tabula WHERE id='54' bez visiem LIMIT būs daudz ātrāks. Tas izmantos id indeksu. SELECT COUNT(*) ir bremzīgais variants. Link to comment Share on other sites More sharing options...
OverBurner Posted February 20, 2004 Author Report Share Posted February 20, 2004 Nu lielu lielais paldies :), es itkaa taisiiju ar taapat bet kaut kur kljuudiijos. tnx < again Link to comment Share on other sites More sharing options...
fassko Posted February 20, 2004 Report Share Posted February 20, 2004 shaads mans piedaavaatais variants $result = mysql_query("SELECT * FROM $tabula WHERE id='..'"); $sk = mysql_num_rows($result); if ($sk == 0){echo "nav taada "; } else { echo "ir taads"; } Link to comment Share on other sites More sharing options...
Recommended Posts