RE: [PHP] Inner Join or 2nd Query...?
| From: | Carl Furst | Date: | Thu, 12 May 2005 13:35:27 +0000 |
| Subject: | RE: [PHP] Inner Join or 2nd Query...? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-215046@lists.php.net to get a copy of this message | ||
If I may,
It depends, are the fields you're joining on indexed? How many keys are
being joined and how many joins are you using. What database are you using?
Which version?
I prefer to use joins myself because it gets all the data in one place.
However if you find that you are using a lot of where statements with your
join you may wish to consider a sub select instead.
A good thing to do would be to try each case and see which works faster in
your situation..
Carl Furst
Vote.com
P.O. Box 7
Georgetown, Ct 06829
203-544-8252
carl@vote.com
-----Original Message-----
From: Mark Sargent [mailto:powderkeg@snow.email.ne.jp]
Sent: Wednesday, May 11, 2005 10:31 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Inner Join or 2nd Query...?
Mark Rees wrote:
>Hi All,
>
>with wanting to show both product types(Switch, Router etc) and
>Makers(Cisco, Avaya, etc) on the one page in select boxes, I was
>wondering, do you use 2 seperate queries to the database or do you inner
>
>join to get all in 1..? I have set up different tables with related id's
>
>etc. So, to get Products.product_name and Products.product_id along with
>
>what the below query pulls, what wold be best..? I believe if I do a 2nd
>
>query, than some variables need to be identified with the particular
>query, yes..? Cheers.
>----------------------------------------
>What is your question in one sentence?
>
>Is it "how do I do an inner join"?
>
>
I guess I was looking for people's opinions, not a specific answer, I
think...
>Is it "are two separate queries on two tables faster than one query on
>both tables"?
>
>
Well, again, no not really. I guess I was curious how others do things.
>Or something else entirely?
>
>
Could be. Sorry, perhaps I'm thinking too general with this, yes..? Cheers.
Mark Sargent.