Jump to content

add a tuple to the result of a query


fatima

Recommended Posts

Hello all,I want to add my own tuple to the final result of a SQL query but I don't know how I can do it.I have query like this:SELECT i.num, 1 AS lable, ‘book’ AS name, book.year AS attributesFROM i, bookWHERE ...and I want to add a tuple with these values to the result for using in some program:(num=null,lable=0,name='bib',attributes=null)I try to write a query like this :) : SELECT null AS num, 0 AS lable, ‘bib’ AS name, null AS attributesFROM ?and UNION that to SQL query but I must write some table name in 'from' clause.what should I do?

Link to comment
Share on other sites

Hello all,I want to add my own tuple to the final result of a SQL query but I don't know how I can do it.I have query like this:SELECT i.num, 1 AS lable, ‘book’ AS name, book.year AS attributesFROM i, bookWHERE ...and I want to add a tuple with these values to the result for using in some program:(num=null,lable=0,name='bib',attributes=null)I try to write a query like this :) : SELECT null AS num, 0 AS lable, ‘bib’ AS name, null AS attributesFROM ?and UNION that to SQL query but I must write some table name in 'from' clause.what should I do?
Just omit the FROM:
SELECT null AS num, 0 AS lable, 'bib' AS name, null AS attributesUNIONSELECT num, label, name, attributes FROM MyTable

Link to comment
Share on other sites

Just omit the FROM:
SELECT null AS num, 0 AS lable, 'bib' AS name, null AS attributesUNIONSELECT num, label, name, attributes FROM MyTable

I thought the 'from' clause is not optional in SQL queries. thanks for your response, I will try it out.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...