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]

Reply via email to