Hi,

I am very new to SQL and I am working on a query. I am to use a flat select statement

I am to :
Print all S#s such that the indicated supplier supplies a
London project and also supplies a Paris project

There are 3 tables, one with supplier information (S), one with jobs (J), one with parts (P) and one with shipments (SPJ).

This is what I have but it doesn't work

SELECT S.s#
FROM S, SPJ, J WHERE
J.city = 'London' or J.city = 'Paris'
and J.j# = SPJ.j#
and SPJ.s# = S.s#

This is returning all the suppliers that ship to either Paris or London but not both.

Please help. Thx

use a select with a subselect

don't know your columns but you basically need to just issue your query twice and use something like

select * from s, spj, j where s.id in 
(select s.id from s, spj, j where j.city='london') and j.location = 'paris'

i didn't put your joins in there, cause i don't know what j# or s# is, but this is how to do it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.