Home > Database > Mysql Tutorial > body text

SQL语句练习实例之七 剔除不需要的记录行

WBOY
Release: 2016-06-07 18:03:49
Original
921 people have browsed it

相信大家肯定经常会把数据导入到数据库中,但是可能会有些记录行的所有列的数据是null,这为null的数据是我们不需要

代码如下:
--相信大家肯定经常会把数据导入到数据库中,但是可能会有些记录行的所有列的数据是null,这为null的数据是我们不需要
--现在需要一个简单的查询来剔除掉这些为null的记录行。
--假设表名为 emplyees
--方法1.
---先把数据导入到数据库
---其次:
select * from sys.columns
where object_id =(select object_id from sys.objects where name='EMPLYEEs')

---方法2
---使用数据库提供的函数
exec sp_columns 'Employees'
delete from Employees where coalesce(status,tel,gwei,ADDRESS1,address2,nwei) is null
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!