I unexpectedly executed the following query in MySQL and got a strange result:
SELECT 'a' 'b' 'c' FROM dual;
The result shows ‘a’ as the column name and ‘abc’ as the value. I am puzzled by this behavior. What is the reason for this?
Feel free to ask if you need any more assistance!
It seems that when using simple constant strings, concatenation occurs. However, I found that if a different type (such as a number) or a database column is included in between, an error occurs.
Let me know if you need anything else!
2
Answers
next to each other without commas or operators, MySQL implicitly
concatenates them. In your case, ‘a’ ‘b’ ‘c’ is interpreted as one
continuous string, resulting in ‘abc’.
for the column, the result is that ‘a’ becomes the column name.
https://dev.mysql.com/doc/refman/8.0/en/string-literals.html
This maybe help.