fatima Posted November 18, 2007 Share Posted November 18, 2007 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 More sharing options...
Reg Edit Posted November 18, 2007 Share Posted November 18, 2007 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 More sharing options...
fatima Posted November 20, 2007 Author Share Posted November 20, 2007 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 More sharing options...
justsomeguy Posted November 20, 2007 Share Posted November 20, 2007 You only need FROM if you're selecting from a specific location. If you're just selecting a literal value there's nowhere to select it from. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.