LeeRoy8888 Posted March 3, 2006 Share Posted March 3, 2006 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 AdvanceLee Link to comment https://forums.phpfreaks.com/topic/4042-mysql-query-using-multiple-orders/ Share on other sites More sharing options...
earl_dc10 Posted March 3, 2006 Share Posted March 3, 2006 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 Link to comment https://forums.phpfreaks.com/topic/4042-mysql-query-using-multiple-orders/#findComment-14019 Share on other sites More sharing options...
LeeRoy8888 Posted March 3, 2006 Author Share Posted March 3, 2006 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 Link to comment https://forums.phpfreaks.com/topic/4042-mysql-query-using-multiple-orders/#findComment-14025 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.