If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Query to return mutliple rows for hardcoded data

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-11, 21:03
tiger66 tiger66 is offline
Registered User
 
Join Date: Dec 2007
Posts: 32
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
Reply With Quote
  #2 (permalink)  
Old 10-24-11, 09:37
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 1,268
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On