gpt4 book ai didi

php - MySQL 单个 SELECT 在 PHP 中显示错误但在 PHPMYADMIN 中不显示

转载 作者:行者123 更新时间:2023-11-29 03:28:29 26 4
gpt4 key购买 nike

在 stackoverflow 上有一些关于它的问题,但只有插入,那又如何呢? :

phpmyadmin 中的 SQL:

SELECT logins.user as user,
logins.id as usid,
rozliczenia.godziny as godziny,
rozliczenia.stawka as stawka,
rozliczenia.premia as premia,
rozliczenia.premiainna as premiainna
FROM logins
LEFT JOIN rozliczenia
ON logins.id=rozliczenia.userid
AND DATE(rozliczenia.data) BETWEEN DATE('2015-01-01') AND DATE('2015-01-31')
WHERE logins.user NOT IN ('SUPERUSER', 'agata', 'tomek')
GROUP BY logins.user
ORDER BY logins.id

它有效,但在 php 中:

$sql = "SELECT logins.user as user, logins.id as usid, rozliczenia.godziny as godziny, rozliczenia.stawka as stawka, rozliczenia.premia as premia, rozliczenia.premiainna as premiainna FROM logins LEFT JOIN rozliczenia ON logins.id=rozliczenia.userid AND DATE(rozliczenia.data) BETWEEN DATE('2015-10-01') AND DATE('2015-10-31') WHERE logins.user NOT IN ('SUPERUSER', 'agata', 'tomek') GROUP BY logins.user ORDER BY logins.id;";
//The same sql
if(!$result = $polaczenie->query($sql)){
return FALSE;
}
while ($rowV = $result->fetch_array())
{
...

它有点工作,但返回:

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 '2015-10-01') AND DATE('2015-10-31') WHERE logins.user NOT IN ('SUPERUSER', '' at line 1

怎么了?

突然间我的更多脚本会返回该错误。我厌倦了这个

编辑

当我删除

WHERE logins.user NOT IN ('SUPERUSER', 'agata', 'tomek')
GROUP BY logins.user
ORDER BY logins.id

它有效,但我需要它。如果我只删除 where 或只删除 group,它不会改变任何东西

最佳答案

也许我错了,但是你的第一个 AND 应该在你的 WHERE 之后。

关于php - MySQL 单个 SELECT 在 PHP 中显示错误但在 PHPMYADMIN 中不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33134513/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com