Jump to content

MySQL Query using multiple ORDERS ?


LeeRoy8888

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
Link to comment
https://forums.phpfreaks.com/topic/4042-mysql-query-using-multiple-orders/
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

Archived

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

×
×
  • Create New...

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.