I am using MySQL. Here is my schema:
Suppliers(sid: integer, sname: string, address string)
Parts(pid: integer, pname: string, color: string)
Catalog(sid: integer, pid: integer, cost: real)
(primary keys are bolded)
I am trying to write a query that selects pairs of sids that supply the same part:
-- Find pairs of SIDs that both supply the same part
SELECT s1.sid, s2.sid
FROM Suppliers AS s1, Suppliers AS s2
JOIN Catalog ON s1.sid = Catalog.sid OR s2.sid = Catalog.sid;
MySQL gives me this error:
ERROR 1054 (42S22): Unknown column
‘s1.sid’ in ‘on clause’
What am I doing wrong?
find parts with two or more suppliers:
find the supplier(s) of those parts, more future-proof, can show two or more suppliers:
but if you want parts which exactly has two suppliers only:
if you want only those two suppliers to display in two columns.. me thinking too… 🙂
[UPDATE]
what i thought up:
to get the supplier names: