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 > Data Access, Manipulation & Batch Languages > ANSI SQL > JOIN based on column value

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-20-06, 07:21
rudgr rudgr is offline
Registered User
 
Join Date: Mar 2006
Posts: 8
JOIN based on column value

Hi,

May be a stupid question, but is it possible to JOIN a certain record based on a column value?

TABLE: PRODUCTS(ID,PRODUCT_ID,PRODUCT_TYPE)
PRODUCTS(1,1,1)
PRODUCTS(1,1,2)
PRODUCTS(1,1,3)

TABLE: PRODUCT_DETAILS_1(1,"aaa")
TABLE: PRODUCT_DETAILS_2(1,"bbb")
TABLE: PRODUCT_DETAILS_3(1,"ccc")

I want to create a query that joins all records in TABLE PRODUCTS to the respective PRODUCT_DETAILS_x TABLE:

If(PRODUCTS.PRODUCT_TYPE = 1)
LEFT JOIN PRODUCT_DETAILS_1 ...
If(PRODUCTS.PRODUCT_TYPE = 2)
LEFT JOIN PRODUCT_DETAILS_2 ...
If(PRODUCTS.PRODUCT_TYPE = 3)
LEFT JOIN PRODUCT_DETAILS_3 ...

etc.
Reply With Quote
  #2 (permalink)  
Old 03-20-06, 08:31
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,455
Cool


Maybe this or this can help.

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
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