这是我的代码:
try
{
$bdd=new PDO('mysql:host=localhost;dbname=cmadatabase','root','@Rugby3390');
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$reponse= $bdd->query('SELECT IR,Level,Type,ToBeAnalyzed,
Supplier,Consequences,Remarks,
SUM(Level,Type,Supplier) AS sommeLvlTypeSup
FROM andgate
GROUP BY IR,Level,Type,ToBeAnalyzed,
Supplier,Consequences,Remarks
ORDER BY SUM(Level,Type,Supplier) ASC');
while ($donnees = $reponse->fetch()){
echo '<p>'.$donnees['IR'].','.$donnees['Level'].','.$donnees['Type'].','.$donnees['ToBeAnalyzed'].','.$donnees['Supplier'].','.$donnees['Consequences'].','.$donnees['Remarks'].','.$donnees['sommeLvlTypeSup'].'<p>';
}
}
catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage();}
?>
这是我的错误:
你可以帮忙吗?我没有看到我的语法错误在哪里?连接失败:SQLSTATE [42000]:语法错误或访问冲突:1064 Erreur de syntaxepr�sde&#39; Type,Supplier)AS sommeLvlTypeSup FROM andgate GROUP BY IR,Level,Type,ToBeAnalyz&#39; �la ligne 1
很多
答案 0 :(得分:0)
尝试改变
"ORDER BY SUM(Level,Type,Supplier)"
到
"ORDER BY sommeLvlTypeSup"
理论上,GROUP / ORDER BY SUM(..)不起作用。
答案 1 :(得分:0)
尝试ORDER BY sommeLvlTypeSup
而不是SUM(Level,Type,Supplier)