Donate

Inner Joins In SQL Server TSQL

Source: TSQL Programming Reference:

An inner join applies two logical query processing phases—it applies a Cartesian product between the two input tables like a cross join, and then it filters rows based on a predicate that you specify. Like cross joins, inner joins have two standard syntaxes: ANSI SQL-92 and ANSI SQL-89.

Using the ANSI SQL-92 syntax, you specify the INNER JOIN keywords between the table names. The INNER keyword is optional because an inner join is the default, so you can specify the JOIN keyword alone. You specify the predicate that is used to filter rows in a designated clause called ON. This predicate is also known as the join condition.

Here are two basic implementations of inner join scripts i created, one with the inner keyword, and the other w/o the inner keyword.

  select distinct l.LoanNum, (c.CusLastName + ', ' + c.CusFirstName + ' '  
     + c.CusMiddleInit) as Name, Status, DateGranted, AmountGranted  
            from loanmaster l  
            join customer c on c.CustomerID = l.CustomerID  
            where l.loannum = 4  
  select distinct l.LoanNum, (c.CusLastName + ', ' + c.CusFirstName + ' '  
     + c.CusMiddleInit) as Name, Status, DateGranted, AmountGranted  
            from loanmaster l  
            inner join customer c on c.CustomerID = l.CustomerID  
            where l.loannum = 4  

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.