[b]myTable5[/b]
(id) mem
[COLOR="Blue"](1) 1[/COLOR]
[COLOR="green"](1) 2[/COLOR]
[COLOR="blue"](2) 1[/COLOR]
[COLOR="green"](2) 2[/COLOR]
[COLOR="blue"](3) 1[/COLOR]
[COLOR="green"](3) 2[/COLOR]
[COLOR="blue"](4) 1[/COLOR]
[COLOR="green"](4) 2[/COLOR]
[COLOR="blue"](5) 1[/COLOR]
[b]myTable5[/b]
(id) mem
[COLOR="blue"](1) 1[/COLOR]
[COLOR="Green"](1) 2[/COLOR]
[COLOR="blue"](2) 1[/COLOR]
[COLOR="blue"](4) 1[/COLOR]
[COLOR="green"](4) 2[/COLOR]
[COLOR="blue"](5) 1[/COLOR]
I have data in myTable5 and myTable6 like the above.
The code1 below added mem=1 in WHERE CLAUSE produces the result below
[b]code1-1[/b]
select id, mem from myTable5
where [COLOR="Blue"]mem=1[/COLOR]
[b]result1-1[/b]
[COLOR="Blue"](1) 1
(2) 1
[COLOR="Red"](3) 1[/COLOR]
(4) 1
(5) 1[/COLOR]
[b]code1-2[/b]
select id, mem from myTable6
where mem=[COLOR="blue"]1[/COLOR]
[b]result1-2[/b]
[COLOR="blue"](1) 1
(2) 1
(4) 1
(5) 1[/COLOR]
The code2 below added mem=2 in WHERE CLAUSE produces the result below
[b]code2-1[/b]
select id, mem from myTable5
where [COLOR="green"]mem=2[/COLOR]
[b]result2-1[/b]
[COLOR="Green"](1) 2
[COLOR="Red"](2) 2
(3) 2[/COLOR]
(4) 2
[/COLOR]
[b]code2-2[/b]
select id, mem from myTable6
where [COLOR="green"]mem=2[/COLOR]
[b]result2-2[/b]
[COLOR="Green"](1) 2
(4) 2
[/COLOR]
I like to produce my target result below
when [COLOR="Blue"]mem=1[/COLOR]
[b]target result[/b]
[COLOR="red"](3)[/COLOR]
when [COLOR="green"]mem=2[/COLOR]
[b]target result2[/b]
[COLOR="Red"](2)
(3)[/COLOR]
The followings are some of my trials for getting my target result.
[b]trial code1[/b]
select myTable5.id from myTable5
left join myTable6 on myTable6.id=myTable5.id
where myTable6.id is null and myTable5.mem=2
[b]trial result2[/b]
(3)
[b]trial code2[/b]
select myTable5.id from myTable5
left join myTable6 on myTable6.id=myTable5.id
where myTable5.mem=2 and myTable6.id is null
[b]trial result2[/b]
(1)
(4)
[b]target result[/b]
(2)
(3)