MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL CROSS JOIN

In MySQL, CROSS JOIN is used to fetch all records from both the tables, where each row in the result set is the combination from both the tables. This is happens because it does not have the join conditions.

MySQL CROSS JOIN Syntax

To fetch all records from both the joined tables, use the following syntax:

Syntax

SELECT col1, col2,....
FROM tablename1
CROSS JOIN tablename2

Parameters:

tablename1 & tablename2: The table name from which you want to fetch records.

col1: The column or field name that will be return.

MySQL CROSS JOIN example

The following MySQL, fetching all records from "tblbankheadquartersandaddress" and "tblbankdemataccountcharges" tables using CROSS JOIN:

Example

SELECT *
FROM tblbankdemataccountcharges 
CROSS JOIN tblbankheadquartersandaddress
LIMIT 10;

Note:

In the above example, we are fetching all record from both "tblbankheadquartersandaddress" and "tblbankdemataccountcharges" tables using CROSS JOIN.

You can use MySQL Command Line Client to fetch all records from both tables without having the join conditions.