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 > Visual Basic > How to add columns to query based on value related table??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-30-10, 02:24
dirkjan75 dirkjan75 is offline
Registered User
 
Join Date: Apr 2010
Posts: 15
How to add columns to query based on value related table??

Hi

I have 3 tabels,
- company
- comp_labels
-labels

the relations are: company - complabels (1:n) labels_comp_labels (1:n), company-labels (m:n). I want to display all records in de companytable with added columns for the labels that apply per company, based on the labels table, joined by the comp_labels table.

To display all results, but per company multiple rows would be something like:
SELECTsome fields
FROM TBL_labels RIGHT JOIN (TBL_company LEFT JOIN TBL_comp_labels ON TBL_company.com_id = TBL_comp_labels.comp_id) ON TBL_labels.label_id = TBL_comp_labels.label_id

But what I want is 1 row per company, displaying all the labelnames individually per column. Any thoughs?
Reply With Quote
Reply

Tags
columns, sql

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On