搜索某字段下空白以外的所有数据 sql?

来源:百度知道 编辑:UC知道 时间:2024/09/23 09:29:28
比如搜索姓名列下所有写了数据的行 这个sql怎么做呢
select * from table where name like '%%'
这是我想的 正确的应该是?
谢谢
在问一个 如果还有name2列 如何把name中的数据转到name2中呢 同时name中的数据清空
---------------------------------------------------------
娃哈哈 都好厉害 我补充分吧 还再这里问问
---------------------------------------------------------
这次想得到的数据是 name name2 两列全非空以外的数据 任意一行
name name2
1 小李 null
2 null 小王
3 null null 如何能得到前2行的数据呢??

可以这样:
select * from table where name is not null and nama<>'';
后面的<>是不等于的意思
‘’里面是一个没有字符但不是null

------------------
楼下十三级来抢饭碗了,不过替你悲哀,授之以鱼不如授之以渔。功利心不可太高,切记,切忌!楼主一味索取,无变通之意,此学习不可取之道也

select * from table where name is not null or name <>'';

--补充--

update table set name2=name,name =''

--补充2--
select * from table where (name is not null or name1 is not null) or (name <>'' or name<>'')

select * from table where name is not null

update table set name2=name
update table set name = null

第二个
select * from table where (name is not null or name2 is not null)

select * from table where name is not null