Jump to content

SQL-Order By


jeffreyd65
 Share

Recommended Posts

I have a line in my php/sql programming, but can't figure out how to include a "ORDER BY" command. $database->setQuery('select `id`, `proj_no`, `proj_name` from t_proj_data where `prog_id`='.$group_id); Do I include it after the $group_id, if so, what would I use as a separator? I tried using a space only, but it didn't work. Any help would be greatly appreciated!!

  • Like 2
Link to comment
Share on other sites

$database->setQuery('select `id`, `proj_no`, `proj_name` from t_proj_data where `prog_id`='.$group_id.' ORDER BY xxxxx'); should work..using the concatenation operator "." (dot).then you can add an ' ORDER BY xxxxx' string with a space at the beginning.. viper

Edited by viper_
Link to comment
Share on other sites

The dot operator is what you use to join strings, like you did before the $group_id variable. Spaces around the operators are optional. The ORDER BY clause goes at the end of that query. http://www.php.net/manual/en/language.operators.string.phphttp://www.w3schools.com/php/php_string.asp

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...