kirk Posted March 31, 2009 Share Posted March 31, 2009 How do I just add a value to a query result. Say my query goes to the table and returns 1,2,3,4 and I want to manually add 5. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 31, 2009 Share Posted March 31, 2009 SELECT 1 AS field1, 2 AS field2, 3 AS field3, 4 AS field4, 5 AS field5That will return a row with 5 fields with the number values in it. Link to comment Share on other sites More sharing options...
kirk Posted March 31, 2009 Author Share Posted March 31, 2009 Lemme reask that. Here is my current query:SELECT MachineFROM ParsedDataWHERE (Date >= @Date1) OR (Date <= @Date2)GROUP BY MachineI want to add "All" to the top of the returned list. Link to comment Share on other sites More sharing options...
jesh Posted March 31, 2009 Share Posted March 31, 2009 Do you mean like this? SELECT Machine AS "All"FROM ParsedDataWHERE (Date >= @Date1) OR (Date <= @Date2)GROUP BY Machine Link to comment Share on other sites More sharing options...
justsomeguy Posted March 31, 2009 Share Posted March 31, 2009 Are you trying to select more than one column?SELECT `Machine`, `All`From ...If you're trying to select every column, you use *:SELECT * FROM... Link to comment Share on other sites More sharing options...
stupor Posted April 1, 2009 Share Posted April 1, 2009 Perhaps you mean to add a "static" entry to the returned set? Try something like ...SELECT Machine='All'UNION<your query>The number, order and data types of the two side of the union must match. You may also find that "All" doesn't appear first in which case you'll have to fiddle around some more ;-) Link to comment Share on other sites More sharing options...
kirk Posted April 1, 2009 Author Share Posted April 1, 2009 Perhaps you mean to add a "static" entry to the returned set? Try something like ...SELECT Machine='All'UNION<your query>The number, order and data types of the two side of the union must match. You may also find that "All" doesn't appear first in which case you'll have to fiddle around some more ;-)Bingo. Thanks man! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.