Re: is there a more efficient query?

From: Date: Sat, 07 Aug 2004 09:11:10 +0000
Subject: Re: is there a more efficient query?
Groups: php.general 
Request: Send a blank email to php-general+get-193069@lists.php.net to get a copy of this message
Well i havent seen anyone been using BETWEEN. Anyway... <?php $SQL = mysql_query("SELECT value FROM table_name WHERE element BETWEEN 48 AND 53"); while($row = mysql_fetch_arrray($SQL)) { print($row['value']); } mysql_free_result($SQL); ?>
From: "Jason Davidson" <jdavidson@zworg.com> To: "Brian Tully" <btully@gstockco.com>, "Jay Blanchard" <jay.blanchard@niicommunications.com>, " PHP" <php-general@lists.php.net> Subject: Re: [PHP] is there a more efficient query? Date: Fri, 6 Aug 2004 09:48:29 -0700 your only getting one row beucase your only pulling one row from the array. You need to loop thru the rows to grab them all. Jason Brian Tully <btully@gstockco.com> wrote: on 8/6/04 12:28 PM, Jay Blanchard at jay.blanchard@niicommunications.com wrote:
[snip] Tis SQL .... SELECT value FROM element_values WHERE user = $user_id AND(element=48 OR element=52 OR and so on....) [/snip] You can also use IN SELECT value FROM element_values WHERE user = $user_id AND element IN ('48', '52',...)
thanks Jay! but that only seems to return the first value. how should I be calling the results? $query2 = "SELECT value FROM element_values WHERE "
        . "(element=48 OR element=49 OR element=50 OR element=51 OR
element=52 OR element=53) "
        . "AND user=$user_id";
$result2 = mysql_query($query2) or die("could not $query2 " . mysql_error()); list($user_name, $address_street, $address_city, $address_state, $address_zip, $phone) = mysql_fetch_array($result2); do i need to do a while loop and create an array or something? thanks again. brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________ Chatt: Träffa nya nätkompisar på Habbo Hotel http://habbohotel.msn.se/habbo/sv/channelizer

« previous php.general (#193069) next »