[SQL] Left joins with multiple tables

2004-01-18 Thread Colin Fox
Hi, all. I've got a bit of a problem here. I have 4 tables - people, a, b, c (not the original names). For each person in the people table, they may or may not have a record in a, may or may not have a record in b, and may or may not have a record in c. Handling the first table (a) is easy: sel

[SQL] Multiple counts

2003-01-01 Thread Colin Fox
Hi, all. I'm trying to calculate two count()s. I have a campaigns table, a campaign_parts table and a people table. Here is a simplified view of 3 tables I'm trying to use: create table campaigns {id serial, company_id int, name varchar(20)); create table campaign_parts(id serial, campaign_id

[SQL] Efficiency Question

2002-09-09 Thread Colin Fox
Hi, all. I'm putting together a small query that should return the most recent entry from a table by date (I can't use an ID field as new entries may be added with older dates). It's not crucial that this run at 100% efficiency, but I'm interested in the results and/or discussion, as this will pr