SQL INNER join query for MySQL

Inner Join Venn diagram Inner Join will return common records appearing in tables.
Inner Join requires two tables to be joined by linking with ON condition. We can add more condition by using WHERE clause.
Area as per venn diagram B
These two table we will use for our examples
Table one ( t1 ) Table two ( t2)
id name1
1one1
2two1
3three1
id name2
1one2
2two2
4four2

QUERY using Inner Join

The common records between two tables will be returned.
SELECT * from t1 INNER JOIN t2 on t1.id=t2.id
idname1idname2
1one11one2
2two12two2

Example: Find out students who have paid fees

We will use inner join to list out students who have paid fees.

student6

Student detils
id, name,class,sex ( 5 records)

student_fee

Payment details
fee id, student id , paid date, amount

You can download SQL Dump of these two tables ( with other tables) here.

SELECT a.id, name,class, sex, dt,amount from student6 a INNER JOIN  student_fee  b ON a.id=b.id
idnameclasssexdtamount
1John DeoFourfemale2013-01-08200
1John DeoFourfemale2013-01-10100
2Max RuinThreemale2013-01-24120
3ArnoldThreemale2013-02-02211
2Max RuinThreemale2013-02-07150
3ArnoldThreemale2013-02-06135
4Krish StarFourfemale2013-02-14100

Subscribe to our mailing list

* indicates required
Subscribe to plus2net
Visitors Rating
Your Rating


Google+
sajid

29-03-2009

this is very easy sum
Lane

11-06-2009

thank you, this was very helpful.
Niyas

21-08-2009

Your Website is Very Helpful for programmers like us, The way of giving examples was superb.
lavanya

27-08-2009

gud website for beginners
Ptarmigan

11-10-2009

a fave website: love anti-style style: craiglist for webbies
Vinod

09-11-2009

Thanks a lot, i got the complete idea of Inner join.
Karu

24-11-2009

How to create Main Table or Inner joint. Please give sql in table level
vimal

03-02-2010

Thanks i got the complete idea of Inner join.
Zameer

16-02-2010

Plus2net is one of the best source to learn :)
fei

02-03-2010

this all tutorial in your web in very helpfull for me. and for beginner programers, thanks
ann

11-03-2010

thanks..!!gud website for beginners...
Narasimha Varman

12-04-2010

thank you plus2net. Its very helpful. Examples shown here are live one.
Garrettraj

16-04-2010

Thanks.....i got the complete idea of Limits.Examples shown here are live one.
jacob

25-07-2010

thanks a lot its wonderful explanation of inner join .................
ashoks

09-10-2010

Thanks i got the complete idea of Inner join.
PJ4YOU

31-10-2010

This is a brilliant way to explain,But I have a question.What is the difference between INNER and SELF Join?
priyalogasamy

18-03-2011

i need to select account numbers from 1 table by checking conditions in other 2 tables
surendra

23-09-2011

Thank you ,i got the full idea about inner join
Prashant Sahu

24-11-2011

Can you tell me differnce between self join, equi join and inner join?
Vikas Yadav

15-05-2012

The representation method is superb..Every biggner can understand easily...Very very thanks ...Vikas
Jyodentist

03-08-2012

Thank you,Good explanation with example.
Subhash Patel

16-08-2012

its learnt by me easily from here.......nicee....
Mainuddin Bhuiyan

31-01-2014

Go ahead...........Don't think ...site is useless
I am use this site 3to 5 times in every week.

Post Comment This is for short comments only. Use the forum for more discussions.




Subscribe to our mailing list

* indicates required
Subscribe to plus2net




HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us
©2000-2017 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer