Jump to content

SQL-Order By


jeffreyd65

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

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

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

Archived

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

×
×
  • Create New...