-2

Here is my SQL query:

SELECT FirstName,
       LastName
FROM Employee,
     Company,
     State,
     Job
WHERE Employee.CompanyID = Company.CompanyID
  AND Company.StateID = State.StateID
  AND State.Abbreviation = 'FL'
  AND Employee.JobID = Job.JobID
  AND (Job.JobCode = 'dev'
       OR Job.JobCode IS NULL)
ORDER BY LastName ASC,
         FirstName ASC;

I am wondering if I should use JOINs for increased efficiency. I am not well versed in query complexity.

I found many sites useful in developing my query such as:

Thank you for your assistance.

  • Yes, you should use JOIN. Any SQL tutorial will tell you that, and show you how to do so. – Ken White Dec 17 '17 at 05:01
  • Probably belongs to codereview.stackexchange.com – Techie Dec 17 '17 at 08:24
  • What do you mean, "wondering if I should use JOINs"? (Edit please.) Joins vs what? `,` is `cross join` with lower precedence & when there are no `outer joins` it doesn't matter what you put in `,` vs `cross join` vs `inner join` or `where` vs `on`. [CROSS JOIN = (INNER) JOIN = comma (",")](https://stackoverflow.com/a/25957600/3404097) The optimization is trivial. Google 'mysql reference manual join optimization'. PS You need to learn basics & how to express what you want in a query in a straightforward way, you don't need to worry about "efficiency". You have no notion of options. – philipxy Dec 17 '17 at 08:49
  • PS Read my comments at your link [INNER JOIN ON vs WHERE clause](https://stackoverflow.com/questions/1018822/inner-join-on-vs-where-clause). Also at the join link above along with my answer. w3schools is trash. Re both qureying & optimization basics read product manuals & there are dozens of introductory textbooks free online plus academic course presentations & videos. – philipxy Dec 17 '17 at 09:07
  • Duplicate of [Explicit vs implicit SQL joins](https://stackoverflow.com/q/44917/3404097) – philipxy Dec 17 '17 at 09:45

1 Answers1

0

The JOIN syntax is typically a lot easier to read so I would recommend it. It will perform just as well as your current syntax if used properly.

Joe Phillips
  • 49,743
  • 32
  • 103
  • 159