我正在尝试在 PHP 中实现枢轴方法,但它给出了一些错误。
表clientdetails
具有 3 个属性 ( clientname
, productname
, quantity
)。
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("HR") or die(mysql_error());
$sql=mysql_query("select clientname, 'Software' as s, 'Desktop' as d
FROM (
select clientname,productname,quantity
FROM clientdetails)
as p pivot (Sum(quantity) for productname in ('Software' ,'Desktop'))") or die("". mysql_error());
其显示错误为
"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 'pivot (Sum(quantity) for productname in ('Software' ,'Desktop'))' at line 5 ".