سؤال

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

هل كانت مفيدة؟

المحلول

Try with ` instead of ' like this :

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

نصائح أخرى

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 
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top