Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting Query Problem

Status
Not open for further replies.

Nematoth

Programmer
Mar 29, 2002
48
MY
I have a problem with MySQL in that when I perform the following:

$sqlquery3 = "select sub_no,sub_name from proj_sub where project_number='$project_number' ORDER BY sub_no;";

$result3 = mysql_query($sqlquery3);

while($row3 = mysql_fetch_array($result3))
{

$sqlquery4 = "INSERT INTO sub_image_issue
VALUES(
'',
'$issue',
'$row3[sub_no]',
'$project_number',
''
);";

$results4 = mysql_query($sqlquery4);
}

The second query 'sqlquery4' inputs data into the table 'sub_image_issue' in a bizarre order and not in the order specified in the query '$sqlquery3'

Any ideas why this might be happening? Thomas Shearer
Multimedia Developer
 
You can't make any assumptions about how records are stored. There is no correlation between the order in which records are inserted and in which order they are retrieved.
The only way to get a result in a certain order is to use an order by clause in the select statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top