Reply to Re: best way to show a mysql join

Your name:

Reply:


Posted by Erwin Moller on 02/01/06 12:34

G0ng wrote:

> I have the following tables:
>
> students
> id, name,....
>
> lessons
> id,description,....
>
> studentslessons
> id,studentid,lessonid,grade
>
> I want to list the lessons of student with name="John" for example.
>
> The one way to do it is :
> select id from students where name="John" and grab the id. then select *
> from studentslessons where studentid=id;
>
> the other is
> select * from students,studentslessons where students.name="john" AND
> students.id=studentslessons.studentid
>
>
> Which is more efficient when using php4 and mysql 4.1? I'm using a
> rather old computer Pentium 800MHz.
>
> thanks

Hi

I fail to see how this is related to PHP. :P

But you can bet the second one is faster because it is only 1 query.

Many databases will first make an executionplan, then execute it.

The quality of the executionplan depends on the database, and possibly
'hints' it received.

In general: Less queries are faster then many queries, and most databases
make good executionplans.

Hope that helps.

Regards,
Erwin Moller

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация