#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    1
    Rep Power
    0

    Single line select


    Hi dont know what to look for oin this one as ive not been able to so far
    Does any one know how to shortcode or do a single line select for a single record in MySQL
    eg...
    $result = mysql_query("SELECT answer FROM table WHERE question='question'");
    while($row = mysql_fetch_array( $result ))
    {
    $answer=$row['answer'];
    }

    converted in to...

    $record = mysql_fetch_array( mysql_query("SELECT answer FROM table WHERE question='question'") ));

    is anything like this possible

    just needing a quick way to get a single record and stop searching when got it

    thanks
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    You can limit the query to returning one row by adding LIMIT 1 to the end of it.


    You say you want a single record, but the example you gave gets a single field.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo