1

Lets say I have 4 tables

Region (RegionCode, RegionName)

Customer (CustCode, CustName, CustAdress, CustBalance, RegionCode)

EmployeeType (EmployeeType, HourlyPayRate,)

Employee (EmployeeNo, EmployeeName, EmployeeAddress, RegionCode, EmployeeType)

My goal is to

List the Employee numbers, names and address of all the employees working in the Region whose code is MUN and the name is John Smith.

My answer is as follows

SELECT EmployeeNo, EmploeeName, EmployeeAddress
FROM Employee
WHERE RegionCode = 'MUN' AND EmployeeName = 'John Smith';

I am tempted to join tables here, but am I right in saying as I can extract all information from this single table Employee I do not have to?

Sean
  • 43
  • 4
  • 2
    Your query seems OK to me in regards to the goal. – sticky bit Dec 06 '19 at 11:53
  • @ sticky bit: thanks I am studying for a paper exam so practicing with a pen and paper :) – Sean Dec 06 '19 at 11:56
  • 1
    I would split the `AND` to a new line and also `EmployeeName = 'John Smith';` I find it makes it easier to remember and understand – Liam Dec 06 '19 at 12:40
  • 1
    Seems OK. But we have to guess what the base tables mean using table & column names. PS Yes-or-no questions are not very helpful & if you must ask then you should give your reasoning, so we can critique it, otherwise what do we say but "because that's how SQL works" & does our answer, yes or no, tell you that your reasoning is right or wrong? (No.) See [ask], other [help] links, hits googling 'stackexchange homework' & the voting arrow mouseover texts. PS [Is there any rule of thumb to construct SQL query from a human-readable description?](https://stackoverflow.com/a/33952141/3404097) – philipxy Dec 07 '19 at 01:49

0 Answers0