0

I have a problem with selecting certain people from a table.

I need to select users from a table if they let's say didn't log in for 6 months.

But in the table we have older information as well. So if we write:

select * from dEmail where date < '2017-06-01'

and if user logged in recently it still selects him. I tried something like this:

select * from dEmail where date < '2017-06-01' and not date > '2017-06-01'

but it doesn't seem to work. Maybe anyone have any suggestions.

1 Answers1

0

Refer to this SQL Fiddle

The sql you are most likely looking for is:

SELECT * 
FROM users 
WHERE LAST_LOGIN >= DATE_ADD(SYSDATE(), INTERVAL - 6 MONTH);

Which will get all users that have not logged in for the last 6 months.

SenSok
  • 138
  • 1
  • 10