PHP中的枢轴方法实现

时间:2013-04-27 04:52:50

标签: mysql

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

表格为clientdetails,包含3个属性(clientnameproductnamequantity)。

<?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 ".

0 个答案:

没有答案