
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How can we write MySQL query for inner joins with the help of Comma operator?
Writing inner joins with the help of comma operator is the most basic way to combine two tables. As we know that we can also write inner join by using keyword INNER JOIN or synonyms like JOIN. To form an inner join we need to specify a particular condition which is known as join-predicate and while writing inner joins using the comma operator, we use WHERE clause, the only way, to specify the join condition. To understand it, we are taking the example of two tables named tbl_1 and tbl_2 which are having following data:
mysql> Select * from tbl_1; +----+--------+ | Id | Name | +----+--------+ | 1 | Gaurav | | 2 | Rahul | | 3 | Raman | | 4 | Aarav | +----+--------+ 4 rows in set (0.00 sec) mysql> Select * from tbl_2; +----+---------+ | Id | Name | +----+---------+ | A | Aarav | | B | Mohan | | C | Jai | | D | Harshit | +----+---------+ 4 rows in set (0.00 sec)
Now, the query below will inner join the above-mentioned tables with comma operator:
mysql> Select * FROM tbl_1,tbl_2 WHERE tbl_1.name = tbl_2.name; +----+-------+----+-------+ | Id | Name | Id | Name | +----+-------+----+-------+ | 4 | Aarav | A | Aarav | +----+-------+----+-------+ 1 row in set (0.00 sec)
- Related Articles
- How can we write MySQL query for cross joins with the help of Comma operator?
- How can we write MySQL query for inner joins with the help of keyword JOIN?
- How can we write MySQL query for cross joins with the help of keyword JOIN?
- How can INTERSECTION between tables be implemented with the help of MySQL joins?
- How DIFFERENCES between tables can be implemented with the help of MySQL joins?
- Which MySQL query can be used with the help of which we can see the list of MySQL databases?
- What is MySQL LEFT JOIN and how can we write MySQL query for it?
- What is MySQL RIGHT JOIN and how can we write MySQL query for it?
- How can we filter data with the help of MySQL subquery?
- How can we create a MySQL view with INNER JOIN?
- How can we check for NULL in a MySQL query?
- Can I search for particular numbers in a MySQL column with comma separated records using a MySQL query?
- Comma separated argument applicable for IN operator in MySQL?
- In MySQL, how can we maintain data-driven table relationship using joins?
- How can we subtract values in MySQL table with the help of LEFT JOIN?

Advertisements