我想两张表联合查询数据,但是想加一个时间限制。时间限制在指定的时间内。精确到时分秒
查询上个月1号 00:00:00到月底最后一天 23:59:59之间的所有数据,table为关联的两个表的表名,t1和t2位表的别名
SELECT * from table t1 INNER JOIN table t2
on t1.xx = t2.xx WHERE t1.create_time BETWEEN
DATE_FORMAT(DATE_ADD(NOW(),INTERVAL -1 MONTH),'%Y-%m-01 00:00:00') and DATE_FORMAT(NOW(), '%Y-%m-01 23:59:59')
你是想加一个对查询数据执行时间的限制,
还是想在sql语句中添加where中的时间范围。
看你的意思像是第一种,比如执行查询,超时,则停止查询。
查询语句中加一个 max_execution_time=2000 SLEEP(20),其它的不变。
SELECT max_execution_time=2000 SLEEP(20), a.* from test a;
有用的话,点个赞吧,加油同学
只取某一段时间数据,我举例是今天0点到下午3点,精确到秒:
select * from table_a a join table_b b
on a.id=b.id
where a.date>= to_date('2022-04-26 00:00:00','yyyy-mm-dd hh24:mi:ss) and
a.date=<to_date('2022-04-26 15:00:00','yyyy-mm-dd hh24:mi:ss)