Ok, I am using Mysql DB. I have 2 simple tables.
Table1 ID-Text 12-txt1 13-txt2 42-txt3 ..... Table2 ID-Type-Text 13- 1 - MuTxt1 42- 1 - MuTxt2 12- 2 - Xnnn
Now I want to join these 2 tables to get all data for Type=1
in table 2
SQL1:
Select * from
Table1 t1
Join
(select * from Table2 where Type=1) t2
on t1.ID=t2.ID
SQL2:
Select * from
Table1 t1
Join
Table2 t2
on t1.ID=t2.ID
where t2.Type=1
These 2 queries give the same result, but which one is faster?
I don't know how Mysql does the Join (or How the Join works in Mysql) & that why I wonder this!!
Exxtra info, Now if i don't want type=1 but want t2.text='MuTxt1', so Sql2 will become
Select * from
Table1 t1
Join
Table2 t2
on t1.ID=t2.ID
where t2.text='MuTxt1'
I feel like this query is slower??