Artificially add a record to MySQL results

Is there a way to skip the record at the top of the result set in MySQL? For example, if my results are:

1 | a
2 | b
3 | c
etc

I want to receive:

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

Where "Select" is not really part of the recordset, but artificially inserted.

Thanks.

+3
source share
4 answers

The only way to achieve this with a query is to use UNION:

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

The correct ordering will depend on how you want the results to be ordered in general.

, ( ) , .

+5
SELECT "Select" as col1, "Select" as col2
UNION
SELECT col1, col2 FROM table
+4

If your request

SELECT Colum1, Column2 FROM Table

to try

SELECT Column1, Column2 from the UNION SELECT table "Select", "Select"

+3
source

Union.

select "Select", "Select"
union
select Col1, Col2 from Table1
+2
source

Source: https://habr.com/ru/post/1716849/


All Articles