I having trouble with this query
it is executing quit well but I cannot make out
how is this select statement working.
Any help or explaination on this problem will be appereciated ..
thank you

select * from emp
where eid 
IN (select eid from works 
     where cid=(select cid from company 
                where city=emp.city))

The query first selects the CID (or city id from what I see) using the employee city shown on the page or in the query.

Then is selects the eid (employee ID's) for all employees whos cid in the works table is equal to the CID pulled from the company data.

It then selects all fields from the employee table whos city is equal to the CID.

Hope that helps

Be a part of the DaniWeb community

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