0

Good morning/afternoon/evening!

I'm trying to run a MySQL query, but it seems to be ignoring the "ORDER BY" clause, most likely, I'm believing, because I'm using the "IN" keyword in my query (several times, as a matter of fact, along with a "LIKE"). Is there a way I can structure my query, so that it will use the "ORDER BY" clause? I've included an example of the query below:

SELECT * FROM Ships, Accounts WHERE Available_Loads.Action != 'D'
AND Ships.Username = Accounts.Username
AND Ships.Username != 'demo'
AND Ships.Status != 'inactive'
AND Ships.PU_Date >= CURRENT_DATE()
AND Ships.Shipment_Type LIKE '%'
AND Ships.Required_Equipment IN ('AC', 'DD')
AND Ships.Origin_Country IN ('USA')
AND Ships.Origin_State IN ('TX')
AND Ships.Origin_City IN ('ALLEN', 'ARGYLE', 'ARLINGTON', 'AUBREY', 'BEDFORD', 'CARROLLTON', 'CEDAR HILL', 'CELINA', 'COLLEYVILLE', 'COPPELL', 'DALLAS', 'DENTON', 'DESOTO', 'DUNCANVILLE', 'EULESS', 'FLOWER MOUND', 'FORT WORTH', 'FRISCO', 'GARLAND', 'GRAND PRAIRIE', 'GRAPEVINE', 'HURST', 'IRVING', 'KELLER', 'LAKE DALLAS', 'LAVON', 'LEWISVILLE', 'LITTLE ELM', 'MCKINNEY', 'MELISSA', 'MESQUITE', 'NORTH RICHLAND HILLS', 'PLANO', 'PRINCETON', 'PROSPER', 'RICHARDSON', 'ROANOKE', 'ROWLETT', 'SOUTHLAKE', 'SUNNYVALE', 'THE COLONY', 'WYLIE')
AND Ships.Dest_Country IN ('USA')
AND Ships.Dest_State IN ('LA') ORDER BY 'PU_Date ASC'

Thanks for any suggestions you can provide!

3
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by wilch
0
AND Ships.Dest_State IN ('LA') ORDER BY 'PU_Date ASC'

In this last line, you have i think mistakenly put the keyword ASC as part of the column name. Try removing the ASC from the quotes !

1
AND Ships.Dest_State IN ('LA') ORDER BY 'PU_Date ASC'

Try removing the ASC from the quotes !

good catch, stared at it and didnt see

Votes + Comments
Thanks for the help with my MySQL query issue!
0

good catch, stared at it and didnt see

I'll give it a shot, but what if I want to specify the ORDER BY clause to be ascending or descending?

0
...AND Ships.Dest_State IN ('LA') ORDER BY 'PU_Date' ASC

The ASC is out of the quotes, what's in the quotes is the column name !

Don't forget to mark as solved, if solved ;)

0

Ah, got it, thanks!

I ended up having to remove the single quotes from the "ORDER BY" clause entirely to get it to work.

Thank you for the guidance and advice, guys! I appreciate it!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.