Question

Is there any way to slip in a record to the top of a result set in MySQL? For instance, if my results are:

1 | a
2 | b
3 | c
etc

I want to be able to get:

Select | Select
1      | a
2      | b
3      | c
etc

Where "Select" isn't actually a part of the recordset, but artificially inserted.

Thanks.

Was it helpful?

Solution

The only way to achieve that with a query would be using UNION:

SELECT 'Select', 'Select'
UNION
SELECT ...

Getting the order correct will depend on how you want the results ordered overall.

If the goal is simply to get a heading at the top of the results, it would be easier (plus more efficient) to just add programmatically in the application that's receiving the data.

OTHER TIPS

SELECT "Select" as col1, "Select" as col2
UNION
SELECT col1, col2 FROM table

If your query is

SELECT Colum1, Column2 FROM Table

try

SELECT Column1, Column2 FROM Table UNION SELECT 'Select', 'Select'

Union.

select "Select", "Select"
union
select Col1, Col2 from Table1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top