문제

I am trying to create a PHP query to delete SQL table rows if the CURDATE column is a year old.

For example, if the current date is 2014/04/1 and the SQL table row's curdate column's data is 2013/04/1 than that table row will be deleted.

For a code example, I am looking for something like:

$sql = "DELETE * from Orders WHERE Curdate == 'CURDATE - 365 days'";
$query = mssql_query($sql);

From my knowledge the above code wouldn't work as it is not correct syntax, but is there something with working syntax that is similar to that?

All help is greatly appreciated.

도움이 되었습니까?

해결책

Try this:

DELETE * from Orders WHERE Curdate == DATE_SUB(curdate(), INTERVAL 1 YEAR)

Read more here.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top