-2

I try to get every record from my MySQL database which is greater than today.

SELECT `contract_to`
     , CURDATE() 
  FROM `contacts` 
 WHERE `contract_to` > 'CURDATE()'

Actual Result I expected
contract_to  |  CURDATE()
2021-03-27   |  2019-03-30

but I got the following

contract_to  |  CURDATE()
2019-03-20   |  2019-03-30
2021-03-27   |  2019-03-30

enter image description here

Strawberry
  • 33,750
  • 13
  • 40
  • 57
Jijo
  • 7
  • 3
  • SELECT contract_to, CURDATE() FROM contacts WHERE contract_to < CURDATE() – Joaozinho das Couves Mar 30 '19 at 07:47
  • 1
    Are the single quotes around curdate() at the end of the query intentional. Try removing them... So your condition is contract_to > CURDATE() – LJ01 Mar 30 '19 at 07:52
  • If you're still struggling, see https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query – Strawberry Mar 30 '19 at 09:53

2 Answers2

0

SELECT contract_to FROM contacts WHERE contract_to > CURDATE();

0

Try this one

SELECT contract_to, CURDATE() FROM contacts WHERE PERIOD_SUB(contract_to,CURDATE())>0

it should do the trick