Danish Bin Sofwan Danish Bin Sofwan - 4 months ago 13
MySQL Question

Add user defined value to a column in an sql query

I have an SQL query:

select DISTINCT shortname_chn from dim_channel;


The query returns me data for example:

| shortname_chn (VARCHAR) |
|__________________________|
| MTV |
| National Geographic|
| Discovery |
| ARY News |


How can I manipulate the SQL query so that I can add an additional row to the returned rows.

Following is the result I wish to get after running some query:

| shortname_chn (VARCHAR) |
|__________________________|
| MTV |
| National Geographic|
| Discovery |
| ARY News |
| ALL |


Where the last row "ALL" is user defined, not present in the database.

In the above mentioned regard, I researched and came across this question : How to add a user defined column with a single value to a SQL query but it targets the problem of adding a whole new column.

Answer
select DISTINCT shortname_chn from dim_channel
UNION 
SELECT 'ALL'
Comments