how to implement a complicated sql command

后端 未结 3 1412
别那么骄傲
别那么骄傲 2021-01-29 11:37

I have a sql table in a MySQL with the following records:

+------+----------+
| user |   dob    |  
+------+----------+
| john | 1/10/96  | 
| jane | 3/4/97   |          


        
相关标签:
3条回答
  • 2021-01-29 12:23
    DELETE FROM users WHERE dob < '2000-01-01'
    

    Please note : I am considering that you are actually saving date in datetime format in MYSQL. Also, you can use various formats for date in MYSQL. Refer : https://stackoverflow.com/a/14051310/6385845

    0 讨论(0)
  • 2021-01-29 12:28

    WIth the help of Delete with Join in MySQL

    I made

    DELETE FROM table_name a
        INNER JOIN (SELECT count(name) as dupesPostMillenia, name 
                    FROM table_name 
                    WHERE dob>'1/1/00' 
                    GROUP BY name ) b on a.name=b.name
        WHERE a.dob < '1/1/00' and b.dupesPostMillenia=0
    

    I think this might help.

    0 讨论(0)
  • 2021-01-29 12:31

    Try this:

    DELETE FROM Users WHERE dob <= '1/1/00'
    
    0 讨论(0)
提交回复
热议问题