日期:2014-05-17  浏览次数:20737 次

这样的查询如何实现
一个表有三个字段,表中有多条记录,如:
Test   (id   char(3)   primary   key,   name1   varchar(10),   name2   varchar(10))

纪录如下:
001     tom       boll
002     mary     merry
003     ton       corry

我现在要这样的一个查询,结果如下:
001     tom       null
002     mary     null
003     ton       null

即不管name2中的值是什么,统统显示null,这个select语句怎么写??

------解决方案--------------------
select id,name1, 'null ' from test

是这样么
------解决方案--------------------
select id,name1,null name2 from test;//应该可以解决你的问题
------解决方案--------------------
select id,name1, 'null ' alias from Test
union
select * from Test2
------解决方案--------------------
select id,name1,null from test
union
select * from test where ...
------解决方案--------------------
select id,name1, 'null ' name2 from test