mysql_query()不能通常解析sql
程序员文章站
2024-04-04 13:05:59
...
mysql_query()不能正常解析sql
一个sql语句,直接放到mysql里运行是正常的
但用php的mysql_query运行该sql后结果却不同,会是mysql_query不能解析的原因吗?
sql如下:
------解决方案--------------------
NSERT INTO analysis.caomei_of_list_pvuv
(region,isp,uv,pv,date)
SELECT
tb2.region,tb2.isp,tb2.uv,tb2.pv,'2014-05-14' AS date
FROM
(
SELECT
tb.region,tb.isp, COUNT(tb.mac) AS uv,
SUM(tb.mac_num) AS pv
FROM
caomei_20140515.caomei_1 AS tb
WHERE
tb.date = '2014-05-14'
GROUP BY tb.region, tb.isp
) AS tb2
LEFT JOIN
(
SELECT
tb6.region,tb6.isp,tb6.uv,tb6.pv
FROM
一个sql语句,直接放到mysql里运行是正常的
但用php的mysql_query运行该sql后结果却不同,会是mysql_query不能解析的原因吗?
sql如下:
INSERT INTO analysis.caomei_of_list_pvuv
(region,isp,uv,pv,date)
SELECT
tb2.region,tb2.isp,tb2.uv,tb2.pv,'2014-05-14' AS date
FROM
(
SELECT
tb.region,tb.isp, COUNT(tb.mac) AS uv,
SUM(tb.mac_num) AS pv
FROM
caomei_20140515.caomei_1 AS tb
WHERE
tb.date = '2014-05-14'
GROUP BY tb.region, tb.isp
) AS tb2
LEFT JOIN
(
SELECT
tb6.region,tb6.isp,tb6.uv,tb6.pv
FROM
analysis.caomei_of_list_pvuv AS tb6
WHERE
tb6.date='2014-05-14'
) AS tb1
ON tb2.region = tb1.region
WHERE
tb1.region IS NULL
AND tb2.region IS NOT NULL
;
------解决方案--------------------
NSERT INTO analysis.caomei_of_list_pvuv
(region,isp,uv,pv,date)
SELECT
tb2.region,tb2.isp,tb2.uv,tb2.pv,'2014-05-14' AS date
FROM
(
SELECT
tb.region,tb.isp, COUNT(tb.mac) AS uv,
SUM(tb.mac_num) AS pv
FROM
caomei_20140515.caomei_1 AS tb
WHERE
tb.date = '2014-05-14'
GROUP BY tb.region, tb.isp
) AS tb2
LEFT JOIN
(
SELECT
tb6.region,tb6.isp,tb6.uv,tb6.pv
FROM
相关文章
相关视频
上一篇: 连接各种数据库的驱动及url