Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 58267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:49:16+00:00 2026-05-10T17:49:16+00:00

I have the following query: SELECT c.* FROM companies AS c JOIN users AS

  • 0

I have the following query:

SELECT c.* FROM companies AS c JOIN users AS u USING(companyid) JOIN jobs AS j USING(userid) JOIN useraccounts AS us USING(userid) WHERE j.jobid = 123; 

I have the following questions:

  1. Is the USING syntax synonymous with ON syntax?
  2. Are these joins evaluated left to right? In other words, does this query say: x = companies JOIN users; y = x JOIN jobs; z = y JOIN useraccounts;
  3. If the answer to question 2 is yes, is it safe to assume that the companies table has companyid, userid and jobid columns?
  4. I don’t understand how the WHERE clause can be used to pick rows on the companies table when it is referring to the alias ‘j’

Any help would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:49:17+00:00Added an answer on May 10, 2026 at 5:49 pm
    1. USING (fieldname) is a shorthand way of saying ON table1.fieldname = table2.fieldname.

    2. SQL doesn’t define the ‘order’ in which JOINS are done because it is not the nature of the language. Obviously an order has to be specified in the statement, but an INNER JOIN can be considered commutative: you can list them in any order and you will get the same results.

      That said, when constructing a SELECT … JOIN, particularly one that includes LEFT JOINs, I’ve found it makes sense to regard the third JOIN as joining the new table to the results of the first JOIN, the fourth JOIN as joining the results of the second JOIN, and so on.

      More rarely, the specified order can influence the behaviour of the query optimizer, due to the way it influences the heuristics.

    3. No. The way the query is assembled, it requires that companies and users both have a companyid, jobs has a userid and a jobid and useraccounts has a userid. However, only one of companies or user needs a userid for the JOIN to work.

    4. The WHERE clause is filtering the whole result — i.e. all JOINed columns — using a column provided by the jobs table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: SELECT * FROM scool LEFT JOIN people as t1
I have the following query: SELECT AccountNumber, RptPeriod FROM dbo.Report ORDER BY AccountNumber, RptPeriod.
I have the following query SELECT * FROM table WHERE id IN (5,4,3,1,6) and
I have the following query: select id from table1 where some_func(?) = 1; where
I have defined the following query: select count((select * from producers)) from producers; Assuming
I have the following query which I want to sort or filter using projected
I have the following query SELECT id AS CLIENT CODE,name AS CLIENT NAME,( SELECT
I have the following query that works under Hibernate but not under eclipse: select
I have 2 tables in my database. One is for orders, and one is
I'm currently working on my private messaging system for my website and so far

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.