根据多个条件从xml列中选择数据

时间:2015-03-31 14:32:18

标签: sql xml

我有xml列的表,需要在表中搜索数据

xml行的结构

<Employees>
 <Emp>
   <Name>Adam</Name>
   <Department>Accounts</Department>
   <Active>1</Active>
 </Emp>
  <Emp>
   <Name>John</Name>
   <Department>Marketing</Department>
   <Active>0</Active>
 </Emp>
  <Emp>
   <Name>Steve</Name>
   <Department>Marketing</Department>
   <Active>1</Active>
 </Emp>
  <Emp>
   <Name>Michel</Name>
   <Department>Marketing</Department>
   <Active>0</Active>
 </Emp>
  <Emp>
   <Name>Joe</Name>
   <Department>Accounts</Department>
   <Active>1</Active>
 </Emp>
</Employees>

我想检查xml dept = accounts中是否存在并且active是否为1

1 个答案:

答案 0 :(得分:0)

.exist('.//Emp[Department/text()[contains(., "Accounts")] and Active/text()[contains(., "1")]]')