Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2007
    Posts
    32

    Unanswered: Query to return mutliple rows for hardcoded data

    Hi

    I am just wondering if it is possible to split one row of data to two rows in sybase without running the same query twice?

    For example, I have a select statement for STORE1
    select "STORE1", a.itemName, b,itemQuantity
    from Item a, ItemCount b
    etc...

    My output would look like
    "STORE1", Candy, 12

    Can I use the same query to also return the same value for store 2 without running the query twice?
    i.e. the result would look like
    "STORE1", Candy, 12
    "STORE2", Candy, 12
    "STORE1", Gum, 3
    "STORE2", Gum, 4


    Many thanks for your input

  2. #2
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    Looking for something like this?
    Code:
    SELECT f.store, o.id, o.name 
    FROM sysobjects o
    , (SELECT 1 UNION ALL SELECT 2 )f(store)
    WHERE id <5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •