0

I want to replace my

SELECT *  FROM TABLE 1, TABLE 2
WHERE tbl1.aaa = tbl2.bbb

to replace something with join clause, and similar other replacements vice verse, is there a quick reference on this?

user3410843
  • 195
  • 3
  • 18

2 Answers2

0

Its as simple as below.

SELECT *  FROM tbl1 INNER JOIN tbl2 ON tbl1.aaa = tbl2.bbb

References to learn about JOIN https://dev.mysql.com/doc/refman/5.0/en/join.html http://www.tutorialspoint.com/mysql/mysql-using-joins.htm

Nilesh Thakkar
  • 1,442
  • 4
  • 25
  • 36
  • @PhillipD, it must be ON missing, since USING requires same column names. – jarlh Apr 09 '15 at 10:08
  • I know I just need a big reference on specifically replacing where statements to join statements. – user3410843 Apr 09 '15 at 10:10
  • This may help you to answer why you should use `JOIN` over `Where` http://stackoverflow.com/questions/2241991/in-mysql-queries-why-use-join-instead-of-where – Nilesh Thakkar Apr 09 '15 at 10:12
0

Try this script:

SELECT *  
FROM TABLE 1 as tbl1 
JOIN TABLE 2 as tbl2
 on tbl1.aaa = tbl2.bbb

or

read this link

whytheq
  • 34,466
  • 65
  • 172
  • 267