现在有两张表A,B。A里有一个开始时间,类型是datetime格式。B存了一个天数,如2天3天。A和B是通过code对应,来获取天数,现在要查询A里的记录,限制条件是 现在的时间-开始时间>天数*24*60*60。如何写sql语句;
谢谢帮忙!
看看我 不行也别怪我
select * from A a where now()-a.startTime > (select day from B )*24*60*60 --B查询肯定要有个where条件 你这也没说是啥
天数还转秒?
----------凑数字的
用php语言吗?$start=strtotime(“2016-6-20 10:10:22”);
$time = time()-$start;
$sql=“select a.* from a left join b on a.code=b.code where time 》??你的条件”
$start=strtotime(“2016-6-20 10:10:22”);
$time = time()-$start;
进行两表联查
$sql=“select a.* from a left join b on a.code=b.code where time 》??你的条件”