This does what I would expect:
mysql> select ExtractValue("<x><a>1</a><b>2</b></x>", "concat(/x/a, /x/b)");
+---------------------------------------------------------------+
| ExtractValue("<x><a>1</a><b>2</b></x>", "concat(/x/a, /x/b)") |
+---------------------------------------------------------------+
| 12 |
+---------------------------------------------------------------+
1 row in set (0.00 sec)
But why does this return "1" instead of "1 2"?
mysql> select ExtractValue("<x><a>1</a><b>2</b></x>", "concat(/x/a, ' ', /x/b)");
+--------------------------------------------------------------------+
| ExtractValue("<x><a>1</a><b>2</b></x>", "concat(/x/a, ' ', /x/b)") |
+--------------------------------------------------------------------+
| 1 |
+--------------------------------------------------------------------+
1 row in set (0.00 sec)
This is a verified bug. MySQL's xpath concatenation operator only considers the first 2 parameters when it should consider all parameters.
https://bugs.mysql.com/bug.php?id=71704
As a workaround you can select the individual values and pass them to the regular concat
function:
select concat(ExtractValue("<x><a>1</a><b>2</b></x>", "/x/a"),' ',
ExtractValue("<x><a>1</a><b>2</b></x>", "/x/b"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With