我的 SQL 语句在我笔记本电脑的 MySQL(服务器版本:5.5.62-0ubuntu0.14.04.1 -(Ubuntu))上正确返回,但在我的服务器(服务器版本:5.7.26-0ubuntu0.16.04.1 -(Ubuntu))上它返回错误。
SELECT *
FROM `orders`
WHERE `mail_sent`='No'
AND `datetime` < DATE_SUB(NOW(), INTERVAL 15 MINUTE)
GROUP BY `contact_id`
ORDER BY `datetime` ASC;
Run Code Online (Sandbox Code Playgroud)
1055 - SELECT 列表的表达式 #1 不在 GROUP BY 子句中,并且包含非聚合列“shop.orders.id”,该列在功能上不依赖于 GROUP BY 子句中的列;这与 sql_mode=only_full_group_by 不兼容
早上好。mysql 5.7.25:
insert into mytable values('2019-03-31 02:06:29')
Run Code Online (Sandbox Code Playgroud)
返回错误“#1292 日期时间值不正确”
但:
insert into mytable values('2019-03-31 03:06:29')
Run Code Online (Sandbox Code Playgroud)
没有错误返回。(字段类型为时间戳)
我哪里错了?
谢谢
奇科
在对我公司的问题进行故障排除时,我更新了表中的所有文件,而不是需要使用测试的特定文件。
create table _file_*date*_BAK as select * from _file;
update _file set category = 'null';
commit;
Run Code Online (Sandbox Code Playgroud)
尝试修复它时,我尝试从备份文件中提取,但出现错误
update (select a.category as OLD, b.category as NEW
from _file a inner join _file_*date*_BAK b on a.filecod = b.filecod) t
set t.old = t.new;
Run Code Online (Sandbox Code Playgroud)
错误报告 -
SQL Error: ORA-01779: cannot modify a column which maps to a non key-preserved table
01779. 00000 - "cannot modify a column which maps to a non key-preserved table"
*Cause: An attempt was made to insert or update …Run Code Online (Sandbox Code Playgroud) 运行 MySQL 8.0.16,据我所知,设置保留为默认值。
我有一张桌子,我们称之为 the_table,有列
id: bigint 主键 auto_increment
the_time:日期时间
我有一个记录,the_time 为 2019-12-19 00:00:00。
当我运行
SELECT id, the_time
FROM the_table
WHERE the_time BETWEEN '2019-12-19' AND '2019-12-19';
SELECT id, the_time
FROM the_table
WHERE COALESCE(the_time, DATE('9999-1-1')) BETWEEN '2019-12-19' AND '2019-12-19';
Run Code Online (Sandbox Code Playgroud)
我得到那个记录。然而,随着
SELECT id, the_time
FROM the_table
WHERE COALESCE(the_time, '9999-1-1') BETWEEN '2019-12-19' AND '2019-12-19';
Run Code Online (Sandbox Code Playgroud)
我没有,虽然将其更改为
SELECT id, the_time
FROM the_table
WHERE COALESCE(the_time, '9999-1-1') BETWEEN '2019-12-18' AND '2019-12-20';
Run Code Online (Sandbox Code Playgroud)
我突然又做了。为什么 MySQL 会这样?为什么额外的 DATE() 会有所作为?我原以为日期和字符串格式之间的转换是双射的,不应该影响计算,但似乎确实如此。为什么只是合并会对是否找到非空记录产生影响?