-1

This is the SQL statement:

mysql -u user -p password -e  "SELECT concat(name,'-',number) from users 
where email='test@test.com'"

Expected output: john-1234

Actual output: concat(name,'-',number)
               john-1234

Why is this happening?

jarlh
  • 40,041
  • 8
  • 39
  • 58
Barath R
  • 189
  • 2
  • 11

3 Answers3

0

MySQL will return column names. You can give it a more useful alias like this:

SELECT concat(name,'-',number) as username from users 
where email='test@test.com'

EDIT: Looks like @jarlh beat me to it in the comments.

Jim Wright
  • 5,570
  • 1
  • 13
  • 31
0

just give an alias of your column name other wise it will concat(name,'-',number) as column name

"SELECT concat(name,'-',number) as output from users 
where email='test@test.com'"
Zaynul Abadin Tuhin
  • 30,345
  • 5
  • 25
  • 56
0

It is name of the column.

You can name it in other way:

SELECT concat(name,'-',number) AS nameAndNumber from users where email='test@test.com'
Vlad Hanzha
  • 434
  • 3
  • 11