I have a database site I have been doing for the past few months and have been struggling with the sort order that the customer wants for the data display.
For example:
Here is some test data:
CustomerNumber=1
CustomerName=ABC Company
[email protected]
CustomerNumber=2
CustomerName=BCD Company
CustomerEmail=NULL
CustomerNumber=3
CustomerName=CDE Company
[email protected]
My client told me that he wanted me to sort first by CustomerEmail (if they have one) and then alphabetically by CustomerName so here is the SQL I came up with.
"SELECT * FROM table ORDER BY CustomerEmail, CustomerName"
By his wants it should sort 1,3,2 but what it does is sort 3,1,2 which makes sense.
Should I modify my SELECT statement to do this (and how) or should I just reorder my array after the database result has been returned?
The database is MySQL FYI.
TIA Chris Sommer
For example:
Here is some test data:
CustomerNumber=1
CustomerName=ABC Company
[email protected]
CustomerNumber=2
CustomerName=BCD Company
CustomerEmail=NULL
CustomerNumber=3
CustomerName=CDE Company
[email protected]
My client told me that he wanted me to sort first by CustomerEmail (if they have one) and then alphabetically by CustomerName so here is the SQL I came up with.
"SELECT * FROM table ORDER BY CustomerEmail, CustomerName"
By his wants it should sort 1,3,2 but what it does is sort 3,1,2 which makes sense.
Should I modify my SELECT statement to do this (and how) or should I just reorder my array after the database result has been returned?
The database is MySQL FYI.
TIA Chris Sommer