Jump to content

Archived

This topic is now archived and is closed to further replies.

LeeRoy8888

MySQL Query using multiple ORDERS ?

Recommended Posts

Hi All,

I'm hoping someone can help with a hopefully simple question.

Is it possible to run a MySQL query with multiple oders statements. I'm hopeing to sort via a "Upgrade1" field and then by company name. Is this possible? I have included the basic code I have at the moment but it's only sorting via company and not both.....

[code]
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query1="SELECT *  FROM `contacts` WHERE `company` LIKE '%' AND `upgrade1` = 'Y' ORDER BY `company` ASC";
[/code]

Please Help!!

Thanks in Advance
Lee

Share this post


Link to post
Share on other sites
try this :

change
[code]
$query1="SELECT *  FROM `contacts` WHERE `company` LIKE '%' AND `upgrade1` = 'Y' ORDER BY `company` ASC";
[/code]

to
[code]
$query1 = "SELECT * FROM 'contacts' WHERE 'company' LIKE '%' AND 'upgrade1' = 'Y' ORDER BY 'company', 'upgrade1' ASC";
[/code]

your ORDER BY statement only said to order by company

Share this post


Link to post
Share on other sites
Hi earl_dc10,

This is exactly what I needed to know. I had previous tried quite a few variations previously without any joy.

Thanks Again!!!

Lee

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.