Question

select concat(Sno,Table) as STB from levels

Above query gives error if run as it is. Say i have valuse in levels as

Sno   Table
1     Sale
2     Stock

I need to fetch them as

STB
---
1Sale
2Stock

What can be the solution other than changing the column name because putting quotes around the word 'Table' gives the wrong output as it becomes just a string

Was it helpful?

Solution

Try with ` instead of ' like this :

SELECT CONCAT(Sno,`Table`) AS STB FROM levels

OTHER TIPS

Use backticks for reserved words.

select concat(Sno, `Table`) as STB from levels

Though in general, if you can avoid using reserved words for database, table, or column names in the future, that's a good idea.

select concat(Sno,`Table`) as STB 
from levels 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top