FALCONSEYE
Programmer
i have two queries as follows
SELECT users.userid
FROM products, userhist a, users
WHERE users.userid = a.userid
AND a.productid = products.productid
AND eventid = 3 -- successfull orders
AND a.datemodified between '6/1/2005' and '6/15/2005'
AND a.userid not in (SELECT MAX(datemodified) from userhist b where statusid in(3,2) and b.userid = a.userid
and eventid = 1)
AND productname = 'Learn Windows®'
which returns
userid
59684
59715
the second query is
SELECT products.productName, emailAddress,
(SELECT MAX(datemodified) from userhist b where statusid in(3,2) and b.userid = a.userid
and eventid = 1) as datemod
, users.userid, eventid, statusid
FROM products, userhist a, users
WHERE users.userid = a.userid
AND a.productid = products.productid
AND eventid = 3 -- successfull orders
AND a.datemodified between '6/1/2005' and '6/15/2005'
AND productname = 'Learn Windows®'
which returns
Learn Windows® test@test1.com NULL 59683
Learn Windows® test@test1.com 2005-06-09 15:03:52.200 59684
Learn Windows® test@test1.com NULL 59694
Learn Windows® test@test1.com NULL 59704
Learn Windows® test@test1.com NULL 59705
Learn Windows® test@test1.com NULL 59714
Learn Windows® test@test1.com 2005-06-09 14:59:12.467 59715
Learn Windows® test@test1.com NULL 59717
Learn Windows® test@test1.com NULL 59718
Learn Windows® test@test1.com NULL 59724
Learn Windows® test@test1.com NULL 59725
Learn Windows® test@test1.com NULL 59734
Learn Windows® test@test1.com NULL 59739
Learn Windows® test@test1.com NULL 59741
Learn Windows® test@test1.com NULL 59749
Learn Windows® test@test1.com NULL 59767
all i want is not to return two users 59684, 59715
from the second query. what am i doing wrong ?
as you will realize the second query returns none null values for these two users. thanks for the help in advance
SELECT users.userid
FROM products, userhist a, users
WHERE users.userid = a.userid
AND a.productid = products.productid
AND eventid = 3 -- successfull orders
AND a.datemodified between '6/1/2005' and '6/15/2005'
AND a.userid not in (SELECT MAX(datemodified) from userhist b where statusid in(3,2) and b.userid = a.userid
and eventid = 1)
AND productname = 'Learn Windows®'
which returns
userid
59684
59715
the second query is
SELECT products.productName, emailAddress,
(SELECT MAX(datemodified) from userhist b where statusid in(3,2) and b.userid = a.userid
and eventid = 1) as datemod
, users.userid, eventid, statusid
FROM products, userhist a, users
WHERE users.userid = a.userid
AND a.productid = products.productid
AND eventid = 3 -- successfull orders
AND a.datemodified between '6/1/2005' and '6/15/2005'
AND productname = 'Learn Windows®'
which returns
Learn Windows® test@test1.com NULL 59683
Learn Windows® test@test1.com 2005-06-09 15:03:52.200 59684
Learn Windows® test@test1.com NULL 59694
Learn Windows® test@test1.com NULL 59704
Learn Windows® test@test1.com NULL 59705
Learn Windows® test@test1.com NULL 59714
Learn Windows® test@test1.com 2005-06-09 14:59:12.467 59715
Learn Windows® test@test1.com NULL 59717
Learn Windows® test@test1.com NULL 59718
Learn Windows® test@test1.com NULL 59724
Learn Windows® test@test1.com NULL 59725
Learn Windows® test@test1.com NULL 59734
Learn Windows® test@test1.com NULL 59739
Learn Windows® test@test1.com NULL 59741
Learn Windows® test@test1.com NULL 59749
Learn Windows® test@test1.com NULL 59767
all i want is not to return two users 59684, 59715
from the second query. what am i doing wrong ?
as you will realize the second query returns none null values for these two users. thanks for the help in advance