Need help with SQL query

I have this sql query but I want to add DESC to it but am getting error ( Error!: SQLSTATE[42000]: Syntax error or access violation: 1064 You have
an error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near ‘DESC LIKE ‘%a%’’
at line 1 ) Pls kindly help me out.

$sql = 'SELECT * FROM business WHERE concat(business_name, " ", business_title) DESC'; 
  foreach($aParams as $i2 => $param):
    if($i2==0):
      $sql = $sql .' LIKE ? ';
    else:  
      $sql = $sql .' AND concat(business_name, " ", business_title) LIKE ? ' ;
    endif;  
  endforeach;  
  #echo DEBUG, '$sql = ',$sql, '<br />';
  return $sql;

DESC is usually used with ORDER BY as in:-

... ORDER BY thisColumn DESC

thanks @SamA74 …I try that and still get same error…where in the sql query am going to put that…I paste the query…where should I put that


$sql = 'SELECT * FROM business WHERE concat(business_name, " ", business_title) ORDER BY business_name  DESC';

or

$sql = $sql .' AND concat(business_name, " ", business_title) LIKE ? ' ;

your WHERE clause seems to be missing a comparison operator and comparand value

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.