0

I'm not quite sure if I'm doing this right, or if there is a way to do this. I'm have the column "name" displaying in alphabetically order, however I'm still trying to get "sales" column to display by DESC. So the last job they submitted is seen first.

<?php 
$result =mysql_query("SELECT * FROM Reports ORDER BY name ASC AND sale DESC") or die(mysql_error());
?>

I've tried combing sql_queries, and WHERE clause, but I can't seem to figure out the correct syntax to do. so If someone could point me in the right direction.

Thanks in advance!

Lauren
  • 40
  • 7
  • 1
    **WARNING**: `mysql_query` is an obsolete interface and should not be used in new applications as it's being removed in future versions of PHP. A modern replacement like [PDO is not hard to learn](http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/). If you're new to PHP, a guide like [PHP The Right Way](http://www.phptherightway.com/) can help explain best practices. – tadman Dec 02 '14 at 17:25
  • the host I'm using is still using PHP 5.3, when the time comes and they switch to 5.5 I'll change to mysqli_*functions – Lauren Dec 02 '14 at 17:30
  • I'd strongly recommend PDO over `mysqli`, it has much better placeholder support, though both are fully supported in PHP 5.3. – tadman Dec 02 '14 at 17:31
  • I'll look into it. I'm don't have a strong background in PHP, my niche is CSS and JavaScript – Lauren Dec 02 '14 at 17:34

3 Answers3

1

Using a comma:

SELECT * FROM REPORTS ORDER BY NAME ASC, SALE DESC

... should work.

Kevin_Kinsey
  • 2,285
  • 1
  • 22
  • 23
0

You Can Use Like This

SELECT * FROM t1 ORDER BY key_part1 DESC, key_part2 ASC;

Example

Example 2

I hope This Will Help you.

Community
  • 1
  • 1
Rohit Gilbile
  • 21
  • 2
  • 9
0

Use this

SELECT * FROM reports ORDER BY name ASC,sale DESC
Rex Rex
  • 1,030
  • 1
  • 8
  • 29