Reputation: 3164
I want to create a virtual column.
It is made of a column, a subquery and fixed string.
The current code uses the subquery as a string and it's not executed.
SELECT X.vname, X.id, CONCAT(X.vname, '..' ,SELECT T.id FROM T WHERE T.x_id=X.id LIMIT 1, '..', 'some_text') FROM xtable AS X
Results as: vname_value..SELECT T.id FROM T WHERE T.x_id=X.id LIMIT 1..some_text
Upvotes: 1
Views: 8557
Reputation: 26386
Try this, surround the sub-query with bracket
SELECT X.vname, X.id, CONCAT(X.vname, '..' ,(SELECT T.id FROM T WHERE T.x_id=X.id LIMIT 1), '..', 'some_text') FROM xtable
Upvotes: 5