for mxl path

Posted 袁言yan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了for mxl path相关的知识,希望对你有一定的参考价值。

 

 

废话不多说,直接上例子 简单明了

create  table tb_class
(
    classId int ,
    className varchar(10)
)
go
insert into tb_class values(1,一班)
insert into tb_class values(2,二班)
insert into tb_class values(3,三班)
go
create table tb_student
(
    classId int,
    stuId varchar(5),
    stuName varchar(10)
)
go
insert into tb_student values(1,1001,张三)
insert into tb_student values(1,1002,李四)
insert into tb_student values(1,1003,王二)
insert into tb_student values(1,1004,麻子)
insert into tb_student values(2,2001,王尼玛)
insert into tb_student values(2,2002,唐马儒)
insert into tb_student values(2,2003,张全蛋)
go
select * from tb_class
select * from tb_student

1.

select stuname from tb_student for xml path

 效果

<row>
  <stuname>张三</stuname>
</row>
<row>
  <stuname>李四</stuname>
</row>
<row>
  <stuname>王二</stuname>
</row>
<row>
  <stuname>麻子</stuname>
</row>
<row>
  <stuname>王尼玛</stuname>
</row>
<row>
  <stuname>唐马儒</stuname>
</row>
<row>
  <stuname>张全蛋</stuname>
</row>

2

select stuname from tb_student for xml path(‘‘)

效果

<stuname>张三</stuname>
<stuname>李四</stuname>
<stuname>王二</stuname>
<stuname>麻子</stuname>
<stuname>王尼玛</stuname>
<stuname>唐马儒</stuname>
<stuname>张全蛋</stuname>

3  

select stuname+, from tb_student for xml path(‘‘)

效果
张三,李四,王二,麻子,王尼玛,唐马儒,张全蛋,

4

select LEFT(stuName, LEN(stuName)-1) from (
select (
select stuname+,from tb_student for xml path(‘‘)) as stuName ) a

张三,李四,王二,麻子,王尼玛,唐马儒,张全蛋

5

select 可以拼接字符串,+LEFT(stuName, LEN(stuName)-1) from (
select (
select stuname+, from tb_student for xml path(‘‘)) as stuName ) a

效果:可以拼接字符串,张三,李四,王二,麻子,王尼玛,唐马儒,张全蛋

以上是关于for mxl path的主要内容,如果未能解决你的问题,请参考以下文章

maven构建SSM--pox.mxl

关于在各浏览器中插入音频文件的html代码片段

如何在 Toad for Oracle 中使用自定义代码片段?

codeblock代码片段

在Tomcat的安装目录下conf目录下的server.xml文件中增加一个xml代码片段,该代码片段中每个属性的含义与用途

Client / Server Interoperability Support Matrix for Different Oracle Versions (Doc ID 207303.1)(代码片段