wetmatter nonsense

let's get random 
Filed under

inner join

 

sqlshots: Querying tables without a (JOIN CLAUSE)

Typically you would use a JOIN clause when querying from multiple tables, but no one said you have to. Say for example you wanted to query two tables (tableA & tableB) which did not have any relationship (no one-to-one at all), yet there are fields in which would permit a comparison. Say street number, pre-direction, street name and the suffix.

Well you would compare
(tableA.street number = tableB.street number) and
(tableA.pre-direction = tableB.pre-direction) and
(tableA.street name = tableB.street name) and
(tableA.suffix = tableB.suffix).

Well I did not have a sample dataset for that illustration but I do have the AdventureWorks database, so here we go.

This first example will illustrate a query using a JOIN clause.

Results

This example illustrates a query without using a JOIN clause.

NOJOIN_Query

Results

As you can see the results are the same, but the queries are a tad different.

-- samson

 

Loading mentions Retweet
Filed under  //   inner join   join clause   joinless queries   quering multiple tables without using a join clause   sql   sqlshots   ssms   tsql  
Posted by Samson Loo 

Comments [0]