2007. 10. 3, szerda keltezéssel 05.21-kor [EMAIL PROTECTED] ezt írta:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company table.
What is the easiest way to query the company table for all the
Actually you still want to use a join, just an OUTER join instead of an INNER
one.
With an OUTER join, you can get all the rows that match as well as rows where
it doesn't match:
http://en.wikipedia.org/wiki/Join_(SQL)#Left_outer_join
In the example there, DepartmentID 36 is present in the
Zoltán Németh wrote:
2007. 10. 3, szerda keltezéssel 05.21-kor [EMAIL PROTECTED] ezt írta:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company table.
What is the easiest way to query the company
- Original Message -
From: Zoltán Németh [EMAIL PROTECTED]
it's not very efficient, but I don't have any better idea. someone else?
Indeed, that sort of query is one of the worst and there is little you can
do to improve it save making sure you have an index on the field of the
you could do a RIGHT OUTER JOIN WHERE the company table is on the right to
show you the companies that do not exist in the contacts table:
SELECT a.name, b.name
FROM contacts a
RIGHT OUTER JOIN company b
ON a.company_id = b.id
WHERE a.name IS NULL;
results:
+--+---+
| name | name
On 10/3/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company
table.
What is the easiest way to query the company table for all the company
rows
whose
[EMAIL PROTECTED] wrote:
I have a company table and a contacts table. In the contacts table, there
is a field called companyID which is a link to a row in the company table.
What is the easiest way to query the company table for all the company rows
whose ID is NOT linked to in the contact