PDA

View Full Version : ORDER BY question


Simiie
01-26-2005, 11:39 PM
I need to order a list of names and in ASC order.

Problem is..

in my database i have a table for 'lastname' which I am using to ORDER BY now in ASC

But some of the names dont have a last name and only have a firstname which is stored in the 'firstname' table.
so they show up on the top of the list ( the ones w/o last names)

Is there a way I can write it to say something like...
$namequery = mysql_query("SELECT * FROM teg_names WHERE letter = '$letterofarray' AND updated = 2 ORDER BY lastname, firstname ASC")or die(mysql_error());

thats my best guess at it... need help! :rolleyes:

Kurashu
01-27-2005, 12:02 AM
You would need ASC after the lastname but yes, you can.

Simiie
01-27-2005, 12:05 AM
it doesnt do it right tho..

with that putting ASC after lastname as well..

it prints out the 'firstname' on top of the 'lastname' names when it generates the list

i need it all mixed in together

Spookster
01-27-2005, 06:49 AM
Why didn't you post this in the MySQL forum?

Moving to MySQL forum...

raf
01-27-2005, 09:38 PM
it doesnt do it right tho..

with that putting ASC after lastname as well..

it prints out the 'firstname' on top of the 'lastname' names when it generates the list

i need it all mixed in together
i've got no idea what you are trying to accomplish. can you post a example of some of your db-records and the desired result ?