chris123321
IS-IT--Management
Here is the query that I'm attempting to write:
Error is: ambigious column name NoteId, NoteName. I've been trying to narrow down which NoteId, NoteName the error by turning the NoteId to lower case, but even after turning all the NoteId(s) to lower case the error still is ambigious column name NoteId.
Any suggestions?
Code:
SELECT NoteID,
NoteName,
SourceID,
UseID
(
SELECT n.NoteID AS NoteID,
n.NoteName AS NoteName,
NULL AS SourceID,
NULL AS UseID
FROM tblNote n
INNER JOIN tblProduct p
ON n.ProductID_F = p.ProductID
WHERE p.ProductID = @ProductID
UNION
SELECT NULL AS NoteID,
NULL AS NoteName
s.SourceID As SourceID,
NULL AS UseID
FROM tblSource s
INNER JOIN tblProduct p
ON s.ProductID_F = p.ProductID
WHERE p.ProductID = @ProductID
UNION
SELECT NULL AS NoteID,
NULL AS NoteName,
NULL AS SourceID,
u.UseID AS UseID
FROM tblUse u
INNER JOIN tblProduct p
ON u.ProductID_F = p.ProductID
WHERE p.ProductID = @ProductID) tblsuNote
LEFT JOIN tblNote n
ON tblsuNote.NoteID = n.NoteID
ORDER BY n.Position, n.Order
Any suggestions?