3

I have a XML like

 <info>
   <name>John</name>
   <sname>Doe</sname>
 </info>

Table with variables like object_name := "name", object_surname = "sname" And MySQL query like

SELECT @name = CONCAT('/info/', object_name) FROM table 

Which give me a variable. @name = '/info/name', it`s OK. Then I do a query:

SELECT ExtractValue(:info, '/info/name') AS name FROM table2

It works fine, but if I change it to

SELECT ExtractValue(:info, @name) AS name FROM table2  

It shows nothing. Do you have some solutions?

3
  • Did you tried @name:? Commented Apr 19, 2016 at 13:02
  • Sorry, I've misunderstand the question. I hope that you could able to find the correct answer. Commented Apr 19, 2016 at 13:18
  • do you set that variable in the same session that you also SELECT? Commented Apr 19, 2016 at 13:18

1 Answer 1

3
SELECT @name = CONCAT('/info/', object_name) FROM table 

compares $name to CONCAT....

= is the assignement operator only for SET,for SELECT use :=

in your case use

SELECT @name := CONCAT('/info/', object_name) FROM table 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.