SELECT V.*
FROM Vendor V
WHERE V.Status = 1
AND V.ExpDate = {ts '2003-12-01 00:00:00'}
AND V.Email IS NOT NULL
AND V.Email != ''
AND V.ID in (SELECT P.ID
FROM Purchase P
WHERE CONVERT(varchar(15),P.ID) = V.PurchaseIDs)
Ray Thompson
Systems Administrator
Tau Beta Pi Association www.tbp.org
The Engineering Honor Society
Integrity and Excellence in Engineering
_____
From: Bradford T Comer [mailto:[EMAIL PROTECTED]
Sent: Friday, January 09, 2004 3:47 PM
To: SQL
Subject: TSQL Question
Can anyone tell me if there is a way to accomplish the following with TSQL?
Current Valid Query:
SELECT
V.*
FROM
Vendor V
WHERE
( (
V.Status = 1
AND
(V.ExpDate = {ts '2003-12-01 00:00:00'})
AND
(V.Email IS NOT NULL
AND
V.Email != '')
) )
There is a field in this table called PurchaseIDs, it is a list of IDs
associated with the Vendor's purchases.
I need to update the above query to ONLY grab Vendors that have valid ID's
in the PurchaseIDs Table, that reference the ID field in the Purchase table;
if that makes sense.
Basically I want something like this, but obviously the EXISTS query is
wrong.
SELECT
V.*
FROM
Vendor V
WHERE
( (
V.Status = 1
AND
(V.ExpDate = {ts '2003-12-01 00:00:00'})
AND
(V.Email IS NOT NULL
AND
V.Email != '')
)
AND
(
EXISTS (
SELECT
P.ID
FROM
Purchase P
WHERE CONVERT(varchar(15), P.ID) IN (V.PurchaseIDs)
)
) )
HELP!
Brad
_____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]
