View Full Version : order by two fields

02-21-2008, 03:05 PM
i have a two field say for example

i want to display the

how would i do that.
i tried this one
select * from table order by field1,field2

but the result is it will sort first the field1 and then field2
acebdf is the result of this query but i want abcdef not this one.please help me

Andrew Johnson
02-21-2008, 04:08 PM
If you have a table setup like that then it is more than likely not normalized, you should consider normalizing all of your tables ASAP.

02-26-2008, 12:30 PM
actually this is the problem.i have field which is idate and sdate.
and i have a display like this

select * from table

if (d==1)
my proble is since there are two fields that displays in the date.how would i sort it.
i cant simply select * from table order by idate and sdate

if any one know how to sort this please help me.

i tried select * from table ordery by concat(idate,sdate)but its not working with this because niether of the field is null

02-26-2008, 12:48 PM
Can you post the table schema?