From: | missive(at)frontiernet(dot)net (Lee Harr) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: SELECT something NOT EQUAL to???? |
Date: | 2001-06-26 20:39:28 |
Message-ID: | 9haru0$5cc$1@node21.cwnet.roc.gblx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 26 Jun 2001 07:27:10 GMT, Sterling <smullett(at)omeninc(dot)com> wrote:
> H-
>
> I have a sql query that I'm constructing and I need it to select all the
> records that are not part of these other records.
>
> For instance.
> $project_id = "1";
>
> table "records"
> project_id int4
> employee_id int4
>
> and contains 5 records
> project_id employee_id
> 1 2
> 1 3
> 2 4
> 2 2
> 2 5
>
> table "list"
> employee_id int4
> name varchar(64)
>
> and contains 4 records
> employee_id name
> 2 John Doe
> 3 Jane Doe
> 4 Bill Smith
> 5 John Denver
>
> I have this statement.
> $sql = "SELECT DISTINCT e.employee_id, e.name, s.project_id
> FROM list e, records s
> WHERE s.project_id != '$project_id'
> ORDER BY last_name ASC";
>
A few problems:
not sure you need to SELECT DISTINCT on this query
s.project_id is int4, so no 'quotes' around the value
what is last_name? it is not in these table definitions
SELECT
e.employee_id,
e.name,
s.project_id
FROM
list e
NATURAL JOIN
records s
WHERE
s.project_id != 1
ORDER BY
name
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-06-26 21:10:53 | Re: Large objects in web applications |
Previous Message | Alex Pilosov | 2001-06-26 19:24:54 | Re: Returning records from function |