What I mean by “virtual” is the following:
For example, you have the following table,
x
Name | Age | Id
John | 22 | 01
Alen | 18 | 02
And when you run the following query:
SELECT name, age, id, "no value" as noVal
FROM Users
it returns the new table by adding “virtual” column
Name | Age | Id | noVal
John | 22 | 01 | no value
Alen | 18 | 02 | no value
My question is, is there a way to add a new “virtual” row, I mean without actually modifying the table or using the INSERT
statement. I think the code should go inside the SELECT
statement.
So for example after adding a new “virtual” row I get the following table:
Name | Age | Id
John | 22 | 01
Alen | 18 | 02
Alex | 25 | 03
Or I can have ‘null’ values for the new “virtual” row.
Advertisement
Answer
Regarding your second question about ‘copy one of the existing rows to the “virtual” row’:
SELECT name, age, id
FROM Users
UNION ALL
SELECT name, age, id
FROM Users
WHERE id = '01'