[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-04 Thread Robert Cummings
On Thu, 2007-10-04 at 11:56 +1000, Chris wrote: Robert Cummings wrote: On Thu, 2007-10-04 at 11:23 +1000, Chris wrote: Robert Cummings wrote: On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote: This is only from my own personal testing. Mind you that I have only been using PostgreSQL

[PHP-DB] [PHP] Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-04 Thread John A DAVIS
left join where item in right table is null "Chris" [EMAIL PROTECTED] 10/3/2007 10:32:01 PM Aleksandar Vojnovic wrote: I would also suggest to limit yourself to things you actually need not to select the whole table.In this case you can't because you're looking for records that exist in

[PHP-DB] Re: [PHP] Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-04 Thread Chris
John A DAVIS wrote: left join where item in right table is null That's still going to look at all records in both tables: 1) so it can work out if there is a match from table 1 to table 2 2) so it can then remember to display any records that don't have a match I was thinking more that if

[PHP-DB] Re: [PHP] RE: the opposite of a join?

2007-10-03 Thread James Ausmus
On 10/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi J, Checkout this, SELECT * FROM tbl_company where id not in (SELECT companyID from tbl_contacts) Brilliant! This is exactly what I was looking for, and is quite logical/readable! Thanks to everyone for the ideas! J

[PHP-DB] Re: [PHP] RE: the opposite of a join?

2007-10-03 Thread Gary Josack
I agree with this. Never use a subquery when a join will work. The optimizer with thank you with performance. James Ausmus wrote: On 10/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi J, Checkout this, SELECT * FROM tbl_company where id not in (SELECT companyID from tbl_contacts)

RE: [PHP-DB] Re: [PHP] RE: the opposite of a join?

2007-10-03 Thread Ryan Jameson \(USA\)
@lists.php.net Subject: [PHP-DB] Re: [PHP] RE: the opposite of a join? On 10/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi J, Checkout this, SELECT * FROM tbl_company where id not in (SELECT companyID from tbl_contacts) Brilliant! This is exactly what I was looking

[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Jim Lucas
Colin Guthrie wrote: Martin Marques wrote: SELECT * FROM company WHERE id NOT IN (SELECT companyID FROM contacts); Not ideal as has been mentioned else where in this thread. Col I think one would have to take into account the DB type being used here. I can have MySQL and PostgreSQL setup

[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Robert Cummings
On Thu, 2007-10-04 at 11:23 +1000, Chris wrote: Robert Cummings wrote: On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote: This is only from my own personal testing. Mind you that I have only been using PostgreSQL for a year or so. But one problem that I have always ran into with

[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Chris
Robert Cummings wrote: On Thu, 2007-10-04 at 11:23 +1000, Chris wrote: Robert Cummings wrote: On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote: This is only from my own personal testing. Mind you that I have only been using PostgreSQL for a year or so. But one problem that I have always

[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Jim Lucas
Robert Cummings wrote: On Wed, 2007-10-03 at 14:49 -0700, Jim Lucas wrote: This is only from my own personal testing. Mind you that I have only been using PostgreSQL for a year or so. But one problem that I have always ran into with MySQL is that when JOIN'ing tables that have large data

[PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Aleksandar Vojnovic
I would also suggest to limit yourself to things you actually need not to select the whole table. Aleksandar Jim Lucas wrote: Colin Guthrie wrote: Martin Marques wrote: SELECT * FROM company WHERE id NOT IN (SELECT companyID FROM contacts); Not ideal as has been mentioned else where in

Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Chris
Aleksandar Vojnovic wrote: I would also suggest to limit yourself to things you actually need not to select the whole table. In this case you can't because you're looking for records that exist in one table that don't exist in another. Apart from looking at the whole table in each case how

Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Aleksandar Vojnovic
It seems you missed my point :) if you would need all the data then select them all, but if you need only partial data from the table then you could limit yourself to that specific columns. I doubt everybody need everything all the time. True? Aleksandar Chris wrote: Aleksandar Vojnovic

Re: [PHP-DB] Re: [PHP] Re: the opposite of a join?

2007-10-03 Thread Chris
Aleksandar Vojnovic wrote: It seems you missed my point :) if you would need all the data then select them all, but if you need only partial data from the table then you could limit yourself to that specific columns. I doubt everybody need everything all the time. True? Ahh - you meant the