-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
  • 42,561
  • 8
  • 45
  • 63
Barath R
  • 199
  • 3
  • 12

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,905
  • 1
  • 15
  • 34
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
  • 31,407
  • 5
  • 33
  • 63
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
  • 464
  • 3
  • 11