如何在查询mysql中使用函数时间

i have this query :

SELECT * 
  FROM news 
 WHERE STATE LIKE 'SI' 
   AND data<'".time()."'  
 ORDER 
    BY data DESC 
 limit 0,1

and i would like to know if the function time it's correct because there is an error on synthase. thank's you !

There are reserved words in MySQL which you cannot use as column names without clearly indicating they are names. See:

https://dev.mysql.com/doc/refman/5.7/en/keywords.html

Both 'data' and 'date' are reserved words. Use back ticks to indicate they are used as names:

$query = "SELECT * 
            FROM `news` 
              WHERE `STATE` LIKE 'SI' 
                AND `data` < '".time()."'  
              ORDER 
                BY `data` DESC 
             LIMIT 0,1

or better, in my opinion, use better column names:

$query = "SELECT * 
            FROM newsItems 
             WHERE itemState LIKE 'SI' 
               AND creationDate < '".time()."'  
             ORDER 
                BY creationDate DESC 
             LIMIT 0,1";

As you can see I had to guess what the columns really stand for, because it's not directly clear from the names. It should be, because that's what they are there for.

TIME() is a function in which you also need to pass your parameter.
So, instead of using it blank like:

select TIME();

you need to use it in this way:

select TIME(now());

Note: In your query, you need to pass like (only if you have datetime field in your table):

AND time(data) < time(now())