Answers for "table joins in mysql"

SQL
0

mysql join

-- MySQL INNER JOINS return all rows from multiple tables where the join condition is met.

SELECT columns
FROM table1 
INNER JOIN table2
ON table1.column = table2.column;

-- LEFT OUTER JOIN
-- Another type of join is called a MySQL LEFT OUTER JOIN. This type of join returns all rows from the LEFT-hand table specified in the ON condition and only those rows from the other table where the joined fields are equal (join condition is met).

SELECT columns
FROM table1
LEFT JOIN table2
ON table1.column = table2.column;

-- RIGHT OUTER JOIN
-- Another type of join is called a MySQL RIGHT OUTER JOIN. This type of join returns all rows from the RIGHT-hand table specified in the ON condition and only those rows from the other table where the joined fields are equal (join condition is met).

SELECT columns
FROM table1
RIGHT JOIN table2
ON table1.column = table2.column;

-- The mySQL CROSS JOIN produces a result set which is the number of rows in the first table multiplied by the number of rows in the second table if no WHERE clause is used along with CROSS JOIN. This kind of result is called as Cartesian Product.

-- If WHERE clause is used with CROSS JOIN, it functions like an INNER JOIN.

SELECT columns
FROM table1 
CROSS JOIN table2;
Posted by: Guest on July-17-2021
0

how to join result table in mysql

SELECT inv.product_id, inv_stock.stock
FROM inventories AS inv

JOIN 

(SELECT product_id, stock
FROM inventories ) AS inv_stock

ON inv.product_id = inv_stock.product_id
 ;
Posted by: Guest on March-21-2021

Code answers related to "SQL"

Browse Popular Code Answers by Language