-2

I have some columns in "user" table like name , email , country, last_online ,as example :

> Mohamed , email , UAE , 2014-06-24 21:43:16
> 
> Ali , email , LY , 2013-05-18 07:13:56
> 
> Zeyad , email , EG , 2011-04-12 19:52:23

i want delete users data whom never logged since 2011-01-01 ,How can i do it ?

Larry Lustig
  • 49,320
  • 14
  • 110
  • 160
Dr.Mezo
  • 807
  • 3
  • 10
  • 25
  • What exactly seems to be a problem? – PM 77-1 Jun 24 '14 at 19:57
  • Study up. http://dev.mysql.com/doc/refman/5.0/en/delete.html – Jaaz Cole Jun 24 '14 at 19:58
  • 1
    http://stackoverflow.com/questions/10643379/how-do-i-query-for-all-dates-greater-than-a-certain-date-in-sql-server may be of help. Once you're happy with your select query, you can change it to a delete: http://dev.mysql.com/doc/refman/5.0/en/delete.html – KathyA. Jun 24 '14 at 19:59
  • 1
    `delete from user where last_login <= '2011-01-01'` – M Khalid Junaid Jun 24 '14 at 19:59
  • @M Khalid Junaid this will delete which users ? below 2011 or above ? – Dr.Mezo Jun 24 '14 at 20:06
  • 1
    First try `select * from user where last_login <= '2011-01-01'`. See the results that you're given. Understand why you get the results you do. Then, change the `select *` to `delete` and rerun the query. The rows that came up in the `select` will be the same rows that are `delete`d. – Andy Lester Jun 24 '14 at 20:12
  • Thanks @Andy Lester , you can copy it as answer so i mark it right :) – Dr.Mezo Jun 24 '14 at 20:36

1 Answers1

0

A basic delete statement is all that you need:

delete from user where last_online <= '2011-01-01'

You should try to read up on basic SQL syntax.

ktbird7
  • 56
  • 8