I have a query as follows :
SELECT distinct(T1.USER_ID)
FROM T1
LEFT OUTER JOIN T2
ON (T1.USER_ID = T2.USERID)
WHERE T2.USERID IS NULL
AND T1.enrolled_date < some_timestamp;
I need to understand how is this not the same as :
SELECT distinct(T1.USER_ID)
FROM T1
WHERE T1.USER_ID IS NULL
AND T1.enrolled_date < some_timestamp;
since we are doing a left join on T1 with T2 on the condition where both user ids are same and checking if t2.user_id is null, can't we just check if t1.user_id is null or not?
I need to implement this on Cassandra (using DataStax), hence I was wondering if I could avoid the join.
this query is saying as " get all of the unique user_id from t1 which do not have a present in t2 (t2.userid is null) that have a value of enrolled_date less than the some_timestamp value
SELECT distinct(T1.USER_ID)
FROM T1
LEFT OUTER JOIN T2
ON (T1.USER_ID = T2.USERID)
WHERE T2.USERID IS NULL
AND T1.enrolled_date < some_timestamp;
The re-written query is not equivalent to the one above. It says, get all unique user_id (NULL) which is null from the single table t1 whose enrolled_date is less than the some_timestamp
SELECT distinct(T1.USER_ID)
--I guess you missed the FROM T1 portion???
WHERE T1.USER_ID IS NULL
AND T1.enrolled_date < some_timestamp;