Search
 
SCRIPT & CODE EXAMPLE
 

SQL

left join vs inner join performance

CREATE TABLE #Test1
(
    ID int NOT NULL PRIMARY KEY,
    Name varchar(50) NOT NULL
)
INSERT #Test1 (ID, Name) VALUES (1, 'One')
INSERT #Test1 (ID, Name) VALUES (2, 'Two')
INSERT #Test1 (ID, Name) VALUES (3, 'Three')
INSERT #Test1 (ID, Name) VALUES (4, 'Four')
INSERT #Test1 (ID, Name) VALUES (5, 'Five')

CREATE TABLE #Test2
(
    ID int NOT NULL PRIMARY KEY,
    Name varchar(50) NOT NULL
)
INSERT #Test2 (ID, Name) VALUES (1, 'One')
INSERT #Test2 (ID, Name) VALUES (2, 'Two')
INSERT #Test2 (ID, Name) VALUES (3, 'Three')
INSERT #Test2 (ID, Name) VALUES (4, 'Four')
INSERT #Test2 (ID, Name) VALUES (5, 'Five')

SELECT *
FROM #Test1 t1
INNER JOIN #Test2 t2
ON t2.Name = t1.Name

SELECT *
FROM #Test1 t1
LEFT JOIN #Test2 t2
ON t2.Name = t1.Name

DROP TABLE #Test1
DROP TABLE #Test2
Comment

PREVIOUS NEXT
Code Example
Sql :: coderbyte sql solutions 
Sql :: Which MySQL statement is used to delete data from a database 
Sql :: mysql select top 2 
Sql :: contact mysql column field 
Sql :: check psql validity function 
Sql :: store case result sql 
Sql :: postgres docs /copy metacomand 
Sql :: mysql read row 
Sql :: closure in sql 
Sql :: create more than 1 tables with references to each other in sqlite3 
Sql :: Limit in access query 
Sql :: sql query for login with email or username 
Sql :: create sql database 
Sql :: create dabase psql 
Sql :: how to make sure two tables have same exact data in sql 
Sql :: how to write query to to display record having maximum value 
Sql :: ACCEPT nome PROMPT on oracle 
Sql :: table values functions in SQL 
Sql :: look at running processes redshift 
Sql :: SOQL Child to parent 
Sql :: mysql order by where condition sub query 
Sql :: tsql rename column name 
Sql :: sql compiler 
Sql :: SQL sort on a calculation 
Sql :: connecting fastapi to mysql server 
Sql :: raiserror sql 
Sql :: https://www.jitendrazaa.com/blog/sql/sqlserver/export-documents-saved-as-blob-binary-from-sql-server/ 
Csharp :: get appdata file path c# 
Csharp :: how do i convert to base64 c# 
Csharp :: open url in c# 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =