I am trying to select multiple column values and concatenate them into one column. I then want to run a LIKE on the column that the values are selected as. However it does not seem to work.
Here is my SQL query.
SELECT col1 + ' ' + col2 + ' ' + col3 AS colname
FROM tblname
WHERE 'colname' LIKE 'test%'
What is wrong with this query? Is there a better way to do this?
Or
This is because column aliases cannot be used in a
WHEREclause. You either need to explicitly right out what the alias defines, or use a subquery to abstract the alias.