I have 2 tables
Bid_customer
|bidkey | customerkey
| 1 | 1
| 1 | 2
| 1 | 3
customer_groups
| groupkey | customerkey
| 1 | 1
| 1 | 2
| 1 | 3
What I’m trying to get is a result that will look like
| bidkey | groupkey
| 1 | 1
I’ve tried a cursor and joins but just don’t seem to be able to get what i need any ideas or suggestions
EDIT: customers can belong to more that one group also
In order to have a working Many-to-Many relationship in a database you need to have an intermediary table that defines the relationship so you do not get duplicates or mismatched values.
This select statement will join all bids with all groups because the customer matches.
Hers is a sample Many to Many Relationship:
For your question:
You will need another table that joins the data. For example,
GroupBidscustomer_groupsandbid_customerwould have a one-to-many relationship withGroupBidsYou would then do the following select to get your data.
This would make sure only related groups and bids are returned