Jump to content

What is better query?

- - - - -

  • Please log in to reply
1 reply to this topic

#1
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
Hi guys

please check this:

SELECT students.name, students.family, section.term, section.group

FROM students, section

WHERE students.id = section.id AND section.course = '234' AND term = '1' AND group = '54'


and this:

SELECT students.name, students.family, section.term, section.group

FROM students

INNER JOIN section

ON students.id = section.id

WHERE section.course = '234' AND term = '1' AND group = '54'


what is better query?

thank you

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
The second one, with the inner join.

The first query will join every row of student with every row of section, and then remove the one he don't need.

The second query will join only the one that are linked together and than do the where, so he will have less data to manipulate




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users