+ -
当前位置:首页 → 问答吧 → 求几句SQL语句,谢谢谢谢。。。。

求几句SQL语句,谢谢谢谢。。。。

时间:2011-12-25

来源:互联网

表的结构如下,有大约2W条数据。


表名theid
id name age
1 张飒 19
2 李思 20
3 18
4 赵柳 22
5 孙二
6 张飒 15
7 王二 17

想删除掉name age 没有参数的整条数据需要结果如下:

id name age
1 张飒 19
2 李思 20
4 赵柳 22
6 张飒 15
7 王二 17


然后想随机对数据库进行重新排列(以下虚拟模仿值,不要求完全按这随机的顺序):

id name age
1 王二 17
2 李思 20
3 张飒 19
4 张飒 15
5 赵柳 22







作者: safjudsoi45   发布时间: 2011-12-25

SQL code
select * from theid
where name is not  null and age is not Null
order by rand()

作者: ACMAIN_CHM   发布时间: 2011-12-25

safjudsoi45 (safjudsoi45)
  '截至2011-12-25 20:40:05 用户结帖率0.00%

当您的问题得到解答后请及时结贴.
http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html

8、如何给分和结贴?
http://community.csdn.net/Help/HelpCenter.htm#结帖


作者: ACMAIN_CHM   发布时间: 2011-12-25

delete from theid
where name is not null or age is not Null
order by rand()

作者: pangpang514   发布时间: 2011-12-25

delete from theid
where name is null or age is Null
order by rand()

作者: pangpang514   发布时间: 2011-12-25

引用 1 楼 acmain_chm 的回复:
SQL code
select * from theid
where name is not null and age is not Null
order by rand()


order by rand()  
这句我是要把数据库的内容变更掉,不是查询出来的结果,该怎么写?

作者: ccccdddeeeaaabb   发布时间: 2011-12-25

引用 4 楼 pangpang514 的回复:
delete from theid
where name is null or age is Null
order by rand()

order by rand()
这句我是要把数据库的内容变更掉,不是查询出来的结果,该怎么写?

作者: ccccdddeeeaaabb   发布时间: 2011-12-25

引用 1 楼 acmain_chm 的回复:
SQL code
select * from theid
where name is not null and age is not Null
order by rand()

还有第一句也不行。。。


我这边要这样写才行是为什么呢?
select * from theid
where name ='' or age = ''

作者: ccccdddeeeaaabb   发布时间: 2011-12-25