[英]MySql Date Time Comparison
I have a table abc
with a field datetime_abc
type-> DATETIME in mysql. 我在mysql中有一个表
abc
,其字段为datetime_abc
type-> DATETIME。 and table xyz
with a field datetime_xyz
type-> DATETIME 和表
xyz
,其字段为datetime_xyz
类型-> DATETIME
I want a query which can separate the Date and Time. 我想要一个可以将日期和时间分开的查询。
select TIME(datetime_xyz) xyz_time_only, DATE(datetime_xyz) xyz_date_only from xyz where.....
This returns me a separate date and time. 这给我返回了一个单独的日期和时间。
Now What i need is 现在我需要的是
select datetime_abc from abc where datetime_abc = xyz_date_only
If I'm not missing something you could try: 如果我不缺少任何东西,您可以尝试:
SELECT datetime_abc FROM abc
WHERE DATE(datetime_abc) = xyz_date_only
Or you could try 或者你可以尝试
SELECT datetime_abc
FROM abc INNER JOIN xyz
ON DATE(abc.datetime_abc) = DATE(xyz.datetime_xyz)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.