Joining of two tables in MySQL

A join is a query that combines rows from two or more tables. In a join query , more than one tables are listed in FROM clause. The function of combining data from multiple tables is called joining. The WHERE clause is used to perform the JOIN function where two or more tables have common attribute.

When two or more tables have common column with same name, the name can be qualified by using table name combined with the period (. ) in referring to the column

We can use natural join or equi join to combines rows from two or more tables.

Consider the following STUDENT and DEPT tables. Write SQL queries for following



Sql queries based on both tables

1] To display student name,department name ,section,marks of only female students

The above query is joining two tables student and dept by equating their rno. The select list consist of fields coming from both the tables. Here both tables have column with same name rno ,so rno can be qualified by using s.rno and d.rno .

In the above query, s and d are table aliases. They are temporary labels given along with table name in FROM clause. We can use table aliases for table names in SELECT and WHERE clauses. We can filter information from join tables by using different conditions. This query only return resultset of female students

2] To Display the student name,department name,section,gender and marks of those student who are scoring marks more than 75

3] To display all information about the students of Computer department


Leave a Reply

Your email address will not be published.