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!

Using DESC for two fields 1

Status
Not open for further replies.

kupe

Technical User
Sep 23, 2002
376
I want to group in descending order the records Sent and also Received when php summons info from the mysql db. When I code

... ORDER BY Received, Sent FROM tbl DESC

Received (or maybe Sent) is treated the wrong way. Be grateful for advice on the correct way.
 
What is *FROM tbl*? The syntax is ORDER BY <table>,<table> DESC.
 
Thanks, Azzazzello, there are two tables. But the fields Received and Sent are on tblOne. So would I say

ORDER BY tblOne.Sent, tblOne.Received, tblTwo DESC

? Doesn't look quite right.
 
The syntax is:[tt]
ORDER BY field1 [DESC], field2 [DESC][/tt]

So you could say[tt]
ORDER BY sent DESC,received[/tt]
or[tt]
ORDER BY sent,received DESC[/tt]
and so on.

There is no need to specify the table names, unless the result set has two fields with the same name. In that case, you would qualify the field name as follows:[tt]
tablename.fieldname[t]]
 
Sorry, slight formatting problem there. It should have been:


The syntax is:[tt]
ORDER BY field1 [DESC], field2 [DESC][/tt]

So you could say[tt]
ORDER BY sent DESC,received[/tt]
or[tt]
ORDER BY sent,received DESC[/tt]
and so on.

There is no need to specify the table names, unless the result set has two fields with the same name. In that case, you would qualify the field name as follows:[tt]
tablename.fieldname[/tt]
 
Great, Tony, much obliged. Good to hear from you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top