views:

48

answers:

4

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.

+2  A: 

Union.

select "Select", "Select"
union
select Col1, Col2 from Table1
Nouveau
+3  A: 

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.

VoteyDisciple
+1 for suggesting efficiency w/adding in the app. thanks
Jason
+3  A: 
SELECT "Select" as col1, "Select" as col2
UNION
SELECT col1, col2 FROM table
Chris McCall
+2  A: 

If your query is

SELECT Colum1, Column2 FROM Table

try

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

jsr