我有这个疑问在这里:返回指定的值,如果没有结果
$query='insert into pageview (visitor,id_realestate,time)
select "q17872745t", 150, now()
from pageview a
where DATE_ADD(now(),INTERVAL -30 MINUTE) > (
select max(time) from pageview b where a.id_realestate=b.id_realestate AND a.visitor=b.visitor
) LIMIT 1';
我想这个部分:
select max(time) from pageview b where a.id_realestate=b.id_realestate AND a.visitor=b.visitor
返回一个日期/时间这是现在( )减去40分钟如果有没有结果
什么是想干什么?你为什么要获得两次“pageview”表?请告诉我们你需要插入什么,我们可以正确地重构你的查询 – Marco 2012-02-13 10:32:45
@Marco看到这个http://stackoverflow.com/questions/9251082/insert-with-a-condition/9251278#9251278 我现在想还插入数据如果组合(访客,价值)不存在。 – 2012-02-13 10:35:14