2

I am trying to execute a simple query on SQL Fiddle

select name as 'user_name' from user_data;

But in the output, the column's alias name is not showing. Instead of showing user_name, it is just showing simply as name.

But when i print a simple query like this..

Select 1 as 'one',2 as 'old'

For the above query, it is showing correct output means Alias name are being displayed.

I have already tried these queries..

select name as user_name from user_data;

select name user_name from user_data;

select name 'user_name' from user_data;

Here is a live link.

So i want to know if there is something wrong with my query or it's just a SQL Fiddle limitation?

Note: I am using MySql 5.6

Akshay Gupta
  • 361
  • 1
  • 6
  • 17

3 Answers3

0

Remove Apex from your alias column:

select name as user_name from user_data;
rdn87
  • 739
  • 5
  • 18
0

All this selects is correct:

Select ud.1 as one, ud.2 as old from user_data as ud;
Select 1 as one, 2 as old from user_data as ud;
Select 1 one, 2 old from user_data;
Select 1 `one more`, 2 old from user_data;
Select 1 one_more, 2 old from user_data;

Don't use ' separator for column names. You can also use ` if you need to add spaces to column name.

AlexIL
  • 523
  • 3
  • 8
  • 23
0

Remove the as keyword. It works just like this:

SELECT name user_name FROM user_table
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
Hend Tayeb
  • 1
  • 1
  • 2