Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-26-2005, 11:39 PM   PM User | #1
Simiie
New to the CF scene

 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Simiie is an unknown quantity at this point
ORDER BY question

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...
PHP Code:
$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!
Simiie is offline   Reply With Quote
Old 01-27-2005, 12:02 AM   PM User | #2
Kurashu
Regular Coder

 
Join Date: Aug 2004
Location: The US of A
Posts: 767
Thanks: 1
Thanked 0 Times in 0 Posts
Kurashu is an unknown quantity at this point
You would need ASC after the lastname but yes, you can.
Kurashu is offline   Reply With Quote
Old 01-27-2005, 12:05 AM   PM User | #3
Simiie
New to the CF scene

 
Join Date: Jan 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Simiie is an unknown quantity at this point
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
Simiie is offline   Reply With Quote
Old 01-27-2005, 06:49 AM   PM User | #4
Spookster
The Infractionator-inator


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 5,509
Thanks: 3
Thanked 10 Times in 10 Posts
Spookster is on a distinguished road
Why didn't you post this in the MySQL forum?

Moving to MySQL forum...
__________________
Spookster
CodingForums Tyrant
All Hail Spookster
Where do you want to go today? Microso... errr Wrong!!! Make the switch Ubuntu Linux
Spookster is online now   Reply With Quote
Old 01-27-2005, 09:38 PM   PM User | #5
raf
Master Coder


 
Join Date: Jul 2002
Posts: 6,589
Thanks: 0
Thanked 0 Times in 0 Posts
raf is on a distinguished road
Quote:
Originally Posted by Simiie
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 ?
__________________
Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html
raf is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:16 PM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.