简体   繁体   中英

Select Data from xml column based on multiple condition

I have table with xml column, need to search data across the table

Structure of xml row

<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>

I want to check if exists in xml dept = accounts and active is 1

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM