sql 怎么根据一个字段的值把数据拆分成多条数据

abcAB4拆成abcAB1AB2AB3AB4... a b c
A B 4
拆成
a b c
A B 1
A B 2
A B 3
A B 4
展开
 我来答
匿名用户
2015-11-26
展开全部
可以这样来查询:

1
2
3
4
5
6
7
8
9
10

<a href="https://www.baidu.com/s?wd=select&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLuWnkrANBuH9hPANBuADv0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtkn16zPHbsrjRYrjmLPjcdPHfs" target="_blank" class="baidu-highlight">select</a> s.a01, s.<a href="https://www.baidu.com/s?wd=a02&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLuWnkrANBuH9hPANBuADv0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtkn16zPHbsrjRYrjmLPjcdPHfs" target="_blank" class="baidu-highlight">a02</a>, 1.000 <a href="https://www.baidu.com/s?wd=as&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLuWnkrANBuH9hPANBuADv0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtkn16zPHbsrjRYrjmLPjcdPHfs"target="_blank" class="baidu-highlight">as</a> a03, s.a04
<a href="https://www.baidu.com/s?wd=from&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLuWnkrANBuH9hPANBuADv0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtkn16zPHbsrjRYrjmLPjcdPHfs" target="_blank" class="baidu-highlight">from</a> table_name s,
(
<a href="https://www.baidu.com/s?wd=select&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLuWnkrANBuH9hPANBuADv0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtkn16zPHbsrjRYrjmLPjcdPHfs" target="_blank" class="baidu-highlight">select</a> 1.000 <a href="https://www.baidu.com/s?wd=as&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLuWnkrANBuH9hPANBuADv0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtkn16zPHbsrjRYrjmLPjcdPHfs" target="_blank" class="baidu-highlight">as</a> val
union
<a href="https://www.baidu.com/s?wd=select&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1YLuWnkrANBuH9hPANBuADv0AP8IA3qPjfsn1bkrjKxmLKz0ZNzUjdCIZwsrBtEXh9GuA7EQhF9pywdQhPEUiqkIyN1IA-EUBtkn16zPHbsrjRYrjmLPjcdPHfs" target="_blank" class="baidu-highlight">select</a> 2.000
union
select 3.000
) c
where s.a03 >= c.val
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式