Jump to content


Photo

MySQL Query using multiple ORDERS ?


  • Please log in to reply
2 replies to this topic

#1 LeeRoy8888

LeeRoy8888
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 March 2006 - 10:40 PM

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.....

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";

Please Help!!

Thanks in Advance
Lee


#2 earl_dc10

earl_dc10
  • Members
  • PipPipPip
  • Advanced Member
  • 71 posts

Posted 03 March 2006 - 10:55 PM

try this :

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

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

your ORDER BY statement only said to order by company
got a problem? Google helps many of those in need

#3 LeeRoy8888

LeeRoy8888
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 03 March 2006 - 11:16 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users