Hello all:
Well in my opinion it is difficult but for some SQL gurus out there it
is probably simple. I have a table with a bunch of bids and another
with a bunch of contractors. Each bid can have any number of
contractors and the contractors can be associated with any number of
bids. So I created a third table to link them which consists of only
ids. What I need to do is grab all the contractors for a specific bid
and display them in a report. Problem is one contractor is marked as
the default and as such I need to have the user enter the default
contractor and then display the bids along with all the other
contractors for that bid.
If something is unclear let me know and I will try to explain better.
Thanks,
JohnSo are you going for this type of result?
SelectedContractor
Bid1
OtherContractor1
OtherContractor2
etc...
Bid2
OtherContractor1
OtherContractor2
etc...
AnotherBid, etc.
OtherContractor1
OtherContractor2
etc...
If so then use two inner joins to connect the two tables with the ID
table and use an IN clause to select all bids and contractors that have
an ID in common with the selected consultant. Following I have an
example that is from a database I'm working on that is set up
identically...just substitute employee with contractor and skill with
bid.
USE dbName
SELECT empEmail, skillName
FROM Skills
INNER JOIN skillList
ON Skills.skillID = skillList.skillID
INNER JOIN Employees
ON Skills.empID = Employees.empID
WHERE Skills.skillID IN
(SELECT skillID
FROM Skills
INNER JOIN Employees
ON Skills.empID = Employees.empID
WHERE empEmail = 'employee@.company.com')
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment