mysql - Is this SQL query correct -


i'm preparing exam in databases , stumbled upon question:

we have database of human resources company, contains tables:

applicant(a-id,a-city,a-name)

qualified(a-id,job-id) 

there more tables in database won't relevant question asking.

the question was:

we want write query displays each pair (job-id,a-city) names of people living in city qualified job.

does query solve question? why?

select qualified.job-id, applicant.a-city, applicant.a-name  qualified, applicant quailified.a-id=applicant.a-id group qualified.job-id, applicant.a-city  

i think query fine. can't find faults it, lacking actual way check it, , lacking experience sql, me confirm indeed okay.

i suspect need select every value want return or compare, need select applicant.a-id

 select qualified.job-id, applicant.a-id, applicant.a-city, applicant.a-name  qualified, applicant quailified.a-id=applicant.a-id group qualified.job-id, applicant.a-city  

i'm not happy group these, output grouped different job id's , each of job id's grouped city,

i feel question not worded, in terms of actual output required assuming user can select city , job, list people group bys in fact selecters:

   select qualified.job-id, applicant.a-id, applicant.a-city, applicant.a-name      qualified, applicant     quailified.a-id=applicant.a-id     , qualified.job-id = ? , applicant.a-city = ? order  applicant.a-name  

(i aware not use preferred join syntax, don't think op needs in case re: comments above).


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -