yossi
yossi

Reputation: 3164

CONCAT a subquery result and fixed strings

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

Answers (1)

codingbiz
codingbiz

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

Related Questions