如何实现复杂的sql命令 [英] how to implement a complicated sql command
本文介绍了如何实现复杂的sql命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MySQL中有一个带有以下记录的sql表:
I have a sql table in a MySQL with the following records:
+------+----------+
| user | dob |
+------+----------+
| john | 1/10/96 |
| jane | 3/4/97 |
| jill | 1/8/96 |
| jack | 2/9/00 |
| jane | 12/14/07 |
| john | 1/11/98 |
+------+----------+
这是我要执行的命令:
使用dob<删除所有用户. 1/1/00,但如果存在另一个同名用户,且其dob> = 1/1/00,则保留该用户.
delete all users with dob < 1/1/00 but keep a user if there exists another user with the same name whose dob >= 1/1/00.
在此示例中,johns和jill将被删除,而janes和jack将保留.
In this example, the johns and jill would be deleted and the janes and jack would stay.
如何将以上命令转换为sql?
How do I translate the above command into sql?
推荐答案
尝试一下:
DELETE FROM Users WHERE dob <= '1/1/00'
这篇关于如何实现复杂的sql命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文