Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

correlated query help

Please somebody help!
I have 2 tables
table1
pending_id
pending_work_id
pending_timestmp
table2
pending_id
pending_timestmp
I want all the values from table1 but only the records from table2, how can
I accomplish this please!
[285 byte] By [sheryl kemp] at [2007-11-9 21:11:17]
# 1 Re: correlated query help
SELECT *
FROM table1
WHERE EXISTS ( SELECT 1
FROM table2
WHERE table2.pending_id = table1.pending_id
AND table2.pending_timestmp = table1.pending_timestmp )

will give you all the rows in table1 where the PK (if it is pending_id,
pending_timestmp ) exists in table2

--
HTH,
David Satz
Principal Web Engineer
Hyperion Solutions

"sheryl kemp" <sheryl.kemp@bellsouth.com> wrote in message
news:3e835663$1@tnews.web.dev-archive.com...
>
>
> Please somebody help!
>
> I have 2 tables
>
> table1
> pending_id
> pending_work_id
> pending_timestmp
>
> table2
> pending_id
> pending_timestmp
>
> I want all the values from table1 but only the records from table2, how
can
> I accomplish this please!
>
David Satz at 2007-11-11 23:51:15 >