如何将当前时间与MySQL中的时间变量进行比较
我需要编写一个查询,将当前时间与包含一些时间的变量进行比较 SQL查询:如何将当前时间与MySQL中的时间变量进行比较,mysql,datetime,casting,Mysql,Datetime,Casting,我需要编写一个查询,将当前时间与包含一些时间的变量进行比较 SQL查询: select time >= curtime() from appointment; 这里time是有一定时间的变量 这就是我得到的错误: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,NUMERIC) for operation '>='; nested exception is java.sql.SQ
select time >= curtime() from appointment;
这里time
是有一定时间的变量
这就是我得到的错误:
Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,NUMERIC) for operation '>='; nested exception is java.sql.SQLException: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,NUMERIC) for operation '>='
我已经尝试过使用time(now()),但它不起作用。是
约会。time
是日期时间
或类似的数据类型,还是字符串
如果是日期时间
或时间戳
,而不是字符串,可能对系统的完整性最好
无论如何,试试这个
select CAST(time AS DATETIME) >= CURTIME()
您编写表达式的方式可能依赖于某种自动类型强制,最好将其显式化。它可以正常工作,但对这个
select CAST(time AS time)>=CURTIME()
,因为我只需要时间。