I have two sql queries
SELECT sub_id,
sub_sent_code,
date_time
FROM moviedatabase.reg_sub_master
WHERE (date_time >= '2013-01-19'
AND date_time <= '2013-01-29');
and
SELECT sub_id,
sub_sent_code,
date_time
FROM moviedatabase.reg_sub_master
WHERE date_time <= '2013-01-19';
My requirment is from 1st query what ever the result comes that sub_id,sub_sent_code,date_time
should not be present in 2nd query .
I want to make it single query.
EDIT : actually i want the result where date_time >='2013-01-19'
AND date_time <='2013-01-29'
and the sub_id
which i am getting should not the be there before '2013-01-19'
Try :
SELECT sub_id,sub_sent_code,date_time
FROM moviedatabase.reg_sub_master
WHERE (date_time >='2013-01-19'
AND date_time <='2013-01-29')
AND sub_id NOT IN (
SELECT DISTINCT sub_id
FROM moviedatabase.reg_sub_master
WHERE date_time <='2013-01-19;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.