2

I've got table1 and table2 and need to get data out from each of them.

Table1

"id"    "name"      "description"
"1"     "Windows"   "Microsoft Windows 8"

Table2

"id" "type" "name"              "description"
"1"  "22"   "Microsoft Windows" "Microsoft Windows 8 Home"
"2"  "2"    "Not an Edit"       "Not an Edit"

I do the select like this

select table1.name, table1.description, 
table2.name, table2.description 
from table1,table2 
where table2.id=table1.id and table2.`type`=22;

Will using an inner join be quicker or more efficient when selecting some 500+ rows at a time?

I've seen most examples using a inner join to do this.

Captain Skyhawk
  • 3,499
  • 2
  • 25
  • 39
Norman
  • 6,159
  • 23
  • 88
  • 141

3 Answers3

5

No difference, just a syntax difference, internally they yield the same execution plan:

ANSI vs. non-ANSI SQL JOIN syntax

Community
  • 1
  • 1
Tamim Al Manaseer
  • 3,554
  • 3
  • 24
  • 33
3

You can do like this..

select table1.name, table1.description, 
table2.name, table2.description 
from table1 inner join Table2 on  table2.id=table1.id and table2.`type`=22
Amit Singh
  • 8,039
  • 20
  • 29
3

This is the correct answer without join

select t1.*,t2.* from t1,t2 where t1.id=t2.id;
  • Comma is cross join. (With lower precedence than keyword joins.) Also this doesn't answer the question. Also this query doesn't return what the query in the question does. – philipxy Feb 12 '21 at 11:57