Skip to content
Advertisement

Convert SQL WHERE query to JOIN [closed]

I need help converting this WHERE query into JOIN. I will be following the same pattern for other queries. Thank you.

Advertisement

Answer

For the most part, you just change your comma separated tables to JOIN clauses. The “ON” clause of the join is what comes from the WHERE clause

Also, instead of column-based select, you could pullthe category and cuisine joined as well. More efficient than query for every record

Also notice, from left-to-right my “join/on” conditions are listing the left table/alias = what I am joining TO table/alias. Helps keep directional awareness of from here to there the tables are joined.

In addition as other person noted in comment, you are open to SQL-Injection and should always parameterize your queries and clean your input source values… So research into SQL-Injection and data cleansing too.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement