MySQL中獲取當前時間為now(),不同於sqlserver getdate()。
SQLServer轉MySQL除變化top 1 -> limit 1之后報錯:
select 1 from record_visitor where visitor_ip='' and datediff(mi,visitor_time,getdate())<=30 limit 1
[Err] 1582 - Incorrect parameter count in the call to native function 'datediff'
搜索了是MySQL->DATEDIFF只計算到天的單位。
正確寫法:
select 1 from record_visitor where visitor_ip='' and TIMESTAMPDIFF(MINUTE,visitor_time,now())<=30 limit 1
