I have two tables, table1 and table2. They both have same columns, program_id, scheduled_time and timezone_id.
I want to retrieve the rows whose have same program_id and timezone_id, but have different scheduled_time from table1.
So here is the sql that I tried:
select t1.*
from table1 t1, table2 t2
where t1.program_id = t2.program_id
and t1.timezone_id = t2.timezone_id
and t1.scheduled_time != t2.scheduled_time;
But I still see rows that have same program_id, scheduled_time and timezone_id.
Could someone fix the sql?
Thanks.
Try something like this:
Basically, do an
INNER JOINon the common columns (program_idandtimezone_id) and make sure thescheduled_timecolumn has a different value.Also: in SQL use the
<>operator –!=is for C# / VB.NET ….