SQL SERVER – Grouping JOIN Clauses In SQL

I always enjoy writing and reading articles about JOIN Clauses. One of my friend and the best ColdFusion Expert Ben Nadel has written good article about SQL JOINs. There are few interesting comments as well at the end of article.

“JOIN grouping is pretty powerful and can get you out of those sticky situations that involve mixed table relationship rules. ” Ben Nadel – Grouping JOIN Clauses In SQL

Reference : Pinal Dave (http://blog.SQLAuthority.com)

10 thoughts on “SQL SERVER – Grouping JOIN Clauses In SQL

  1. Hi,

    what is the difference between inner join and outer join?

    what is the difference between left inner join and right inner join?

    what is the difference between left outer join and right outer join?

    Please explain it.

    Regards,
    Mani…

    Like

  2. Hi mani
    Different between inner join and outer join?
    inner join return only match value from both table but in outer join the all value from one table will be return whther they r match or not …

    2)what is the difference between left inner join and right inner join?
    i think there is a no concept of left inner join or right inner join

    3)what is the difference between left outer join and right outer join?
    left outer join return all the value from first table , and right join return all the value from second table

    Thanx

    Like

  3. Three Types OUTER Joins are available
    1. Left Outer
    2. Righ Outer
    3. Full Outer

    I am going to give small example to explain this
    Table 1 Name – tblStudent
    Columns
    ID – Primary Key
    Name – Not Allow Null
    CityId – Foreign Key Refered ID Column in the City Table
    Allows Null
    Data

    Id Name CityId
    1 Russel 1
    2 Mike NULL

    Table 2 Name – tblCity
    Columns
    ID – Primary Key
    Name – Not Allow Null
    Data
    Id Name
    1 Portland
    2 Seattle

    LEFT OUTER QUERY RESULT
    ————————
    Id Name CityId Id Name
    1 Russel 1 1 Portland
    2 Mike NULL NULL NULL

    RIGHT OUTER QUERY RESULT
    ————————-
    Id Name CityId Id Name
    1 Russel 1 1 Portland
    NULL NULL NULL 2 Seattle

    FULL OUTER QuERY RESULT
    ————————-
    Id Name CityId Id Name
    1 Russel 1 1 Portland
    2 Mike NULL NULL NULL
    NULL NULL NULL 2 Seattle

    Hope it explained you clearly

    Like

  4. I need to join field xyz in 2 tables. In Table 1, xyz is char 16 and in Table 2 xyz is char 17. I can not change the field size in either table. There is one more leading space in Table 2 which cause no data to join together. Any suggestions on how to join them?

    Like

  5. @Cy

    Can you please more details please,

    1. Are you trying to join two columns, meaning concatinating for ex :
    tabA : cola = example
    tabB : colb = example1

    concatination :cola+colb = exampleexample1
    Are you trying for this ? This should be no problem !

    2. Are you trying to join two tables, using join operator.

    select * from tableA , join tableB on cola.tableA= colb.tableB

    Are you trying to do this ? Give me a sample column values from both the tables and I will try to write script.

    Thanks,
    Imran.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s