Mysql Pivot方法在PHP中的实现

Mysql Pivot方法在PHP中的实现,mysql,Mysql,我正在尝试用PHP实现pivot方法,但它给出了一些错误 表是带有3个属性的clientdetails(clientname,productname,quantity) 旁注:当你有机会的时候,你可能会想在将来阅读使用类似的东西。。。(上列出了有关PDO和其他选项的一些信息。)MySQL服务器不支持PIVOT子句,但有一些解决方法,请查看以下链接:,。PIVOT方法在oracle中也不起作用。。此外,给定链接中的查询也不起作用。。!!请查看按clientname从clientdetails组中选

我正在尝试用PHP实现pivot方法,但它给出了一些错误

表是带有3个属性的
clientdetails
clientname
productname
quantity


旁注:当你有机会的时候,你可能会想在将来阅读使用类似的东西。。。(上列出了有关PDO和其他选项的一些信息。)MySQL服务器不支持PIVOT子句,但有一些解决方法,请查看以下链接:,。PIVOT方法在oracle中也不起作用。。此外,给定链接中的查询也不起作用。。!!请查看按clientname从clientdetails组中选择clientname、Sum(如果(productname='Software',quantity,NULL))作为软件Sum(如果(productname='Desktop',quantity,NULL))作为桌面;
<?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 ".