简体   繁体   中英

SQL Compare date

Hi guys I am trying to compare the local date with one of my query , the problem is that I don't know how to do that .

As I know if we run this

SELECT NOW()

It will output something like this 2013-03-23 06:56:55

Now I'd like to update one my row comparing that info but I don't know how to, my idea it's something like this

UPDATE `account`.`account` SET `Level` = '1' 
WHERE `Level` = '2' AND Select NOW() >`last_online`

What I want to prevent is the fact that I am updating the account and the user is online , so I want to compare the last time online with the current date and then run the query if the current date is > than the last time online

Thanks!

EDIT: The server is mysql

Try removing the 2nd SELECT

  UPDATE `account`.`account` 
  SET `Level` = '1' 
  WHERE `Level` = '2' AND NOW() > `last_online` 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM