MySQL LEFT Inner and outer where clause joins

MySQL LEFT Inner and outer where clause joins

Today, We want to share with you .
In this post we will show you Mysql left outer join example where clause, hear for MySQL Inner and outer joins SQL examples we will give you demo and example for implement.
In this post, we will learn about MySQL LEFT JOIN Clause By Examples with an example.

Welcome to the In Pakainfo.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.Mysql left outer join example where clause

A LEFT JOIN in mysql or LEFT OUTER JOIN in mysql gives all the rows data from only the left table data with matched rows and from both tables get data.

MYSQL LEFT JOIN and LEFT OUTER JOIN are the same.

The SQL LEFT JOIN syntax

SELECT table_column_names
FROM table_name1 LEFT JOIN table_name2 
ON table_column_name1 = table_column_name2
WHERE condition
ORDER BY table_column_name

Example 1 : Simple LEFT JOIN

SELECT usermst.username, usergroupmap.userid
FROM usermst
LEFT JOIN usergroupmap
ON usermst.userid=usergroupmap.userid
ORDER BY usermst.username;

Example 2 : LEFT OUTER JOIN

SELECT DISTINCT usermst.device_token 
FROM usermst 
LEFT OUTER JOIN usergroupmap on usermst.userid= usergroupmap.userid 
where trim(usermst.device_token) != '' and usergroupmap.groupid=123 
ORDER BY usermst.userid

Example 3 : the comparison to the on clause : LEFT OUTER JOIN

SELECT salesorder.id, salesorder.data, productid.data
FROM salesorder 
LEFT OUTER JOIN productid
ON salesorder.id = productid.pqid and productid.uid='98256'
ORDER BY salesorder.id LIMIT 2

Example 4 : LEFT OUTER JOIN example using MYSQL

SELECT * 
FROM usermaster 
LEFT OUTER JOIN gusetmst 
ON usermaster.user_id = gusetmst.user_id 
where (tc_date_transaction = "25/04/2017" or tc_date_transaction is null);

Note :

The LEFT JOIN or (join means two table join)keyword data returns all the rows from the left table (usermst).

Leave a Comment