62,266
社区成员
发帖
与我相关
我的任务
分享
declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1
--首页取出一个网上投票
declare @id int
set @id=1
--用○代替单选按钮
select (case type when 0 then [name] else '○ '+[name] end) as 网上调查 from @table where num=@id
/*
网上调查
------------------------
你最喜欢的颜色是什么?
○ 红
○ 黄
○ 蓝
*/
declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1
select * from @table
/*
num name type
----------- --------------------- -----------
1 你最喜欢的颜色是什么? 0
1 红 1
1 黄 1
1 蓝 1
2 你喜欢旅游吗? 0
2 喜欢 1
2 不喜欢 1
*/
--新添加一个投票
insert into @table
select 3,'你去过长城吗?',0 union all
select 3,'去过',1 union all
select 3,'没有',1
select * from @table
--为第一个投票添加一个选项
insert into @table
select 1,'绿',1
select * from @table order by num
--首页取出一个网上投票
declare @id int
set @id=1
select [name] from @table where num=@id
declare @table table (num int,name varchar(21),type int)
insert into @table
select 1,'你最喜欢的颜色是什么?',0 union all
select 1,'红',1 union all
select 1,'黄',1 union all
select 1,'蓝',1 union all
select 2,'你喜欢旅游吗?',0 union all
select 2,'喜欢',1 union all
select 2,'不喜欢',1
select * from @table
/*
num name type
----------- --------------------- -----------
1 你最喜欢的颜色是什么? 0
1 红 1
1 黄 1
1 蓝 1
2 你喜欢旅游吗? 0
2 喜欢 1
2 不喜欢 1
*/