Re: Creating "multiple" rows manually with SELECT

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi there,

You should use the UNION ALL Clause. vis.
SELECT * FROM (SELECT 'Apple' AS FRUIT
UNION ALL
SELECT 'Banana' AS FRUIT
UNION ALL
SELECT 'Cherry' AS FRUIT) A

Hope this helps,

Charley Hanania

Hi All,

In T-SQL is there a way for a subquery to manually create multiple
rows?
i.e.
If I don't have the luxury building a temp table on-the-fly, is there
a way to create rows?
e.g.
If I want an intermediate table to have
Apple
Banana
Cherry
in 3 rows with a column called FRUIT,
is there a way to do that on the fly?

Example, you can create one row such as:
select *
from (
select 'Apple' as fruit
) as a
But is there a way to get three (or more) rows?

Thanks in advance.



.



Relevant Pages

  • Picked this morning - long post
    ... Quinces are members of the rose family, closely related to pears, and more distantly to apples. ... Some people find them tricky to grow, and they tend to drop their leaves if they don't like the conditions; their fruit also rots fairly easily, so doesn't keep. ... Japanese Quinces, also known as "japonica", are any of the Chaenomeles species. ... They can be used in most recipes instead of either apple or quince, but need more sugar for sweet ones. ...
    (uk.people.silversurfers)
  • Re: 7-Foot Robot Used in Black Sea Expedition
    ... I know well that the fruit ... > involved was not an apple, yet it is called an apple, and was ... > reliefs of the Goddess of the Water Tresses, ... >> the Snake, ...
    (sci.archaeology)
  • Re: 7-Foot Robot Used in Black Sea Expedition
    ... I know well that the fruit ... > involved was not an apple, yet it is called an apple, and was ... > reliefs of the Goddess of the Water Tresses, ... >> the Snake, ...
    (sci.lang)
  • Re: Items added to fruit salad well in advance
    ... fresh orange juice to keep it wet. ... now i guess i will have to put in the apple and banana at the last minute ... wouldn't add banana to a fruit salad regardless, ...
    (rec.food.cooking)
  • Re: Aw, Jeez. Another Nooby Infestation
    ... (defun fruits-but (fruit) ... (APPLE APRICOT BANANA) ... #(NIL NIL NIL NIL ...
    (comp.lang.lisp)