Optimize my sql query

I have couple auto increment s.no and respective names in my mysql database.

Currently the queries written are like below.

    $result = mysql_query ("SELECT name FROM table WHERE s.no= '1'") or die (mysql_error ());
    while($row = mysql_fetch_array($result)){

    $name1= $row['name'];
    }

    $result = mysql_query ("SELECT name FROM table WHERE s.no= '2'") or die (mysql_error ());
    while($row = mysql_fetch_array($result)){

    $name2= $row['name'];
    }

How could this be optimized, to have a single query and assign name1 from s.no=1, nameN from s.no=N??

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories