opensips db 의 subscriber 테이블 와 location 테이블 의 username 값 비교 location 테이블에만 잇는 username 추룰
SELECT * from opensips.subscriber a RIGHT OUTER JOIN ( SELECT username , contact from location where MID(user_agent,1,17) = 'Sipdroid/3.8.01.2') b on a.username = b.username where a.username is null;
참조
SELECT *
FROM forum_cat c LEFT JOIN
(SELECT t.cat_id,
p.topic_id,
t.title,
p.id,
p.body,
MAX(p.`date`) AS `date`,
p.author_id,
u.username
FROM forum_post p INNER JOIN
forum_topic t ON t.id = p.topic_id INNER JOIN
`user` u ON u.user_id = p.author_id
GROUP BY t.cat_id) d ON d.cat_id = c.id
WHERE c.main_cat = 1
ORDER BY c.list_no
create table tableA ( EMPNO int)
create table tableB ( EMPNO int)
insert into tableA values (1)
insert into tableA values (2)
insert into tableA values (3)
insert into tableA values (4)
insert into tableA values (5)
insert into tableB values (1)
insert into tableB values (2)
insert into tableB values (3)
insert into tableB values (4)
insert into tableB values (7)
-- A 테이블에만 존재하는 항목
select A.EMPNO
from tableA A left outer join tableB B on A.EMPNO=B.EMPNO
where B.EMPNO is null
-- B 테이블에만 존재하는 항목
select B.EMPNO
from tableA A right outer join tableB B on A.EMPNO=B.EMPNO
where A.EMPNO is null
-- A, B 테이블에 서로 없는것을 동시에
select A.EMPNO
from tableA A left outer join tableB B on A.EMPNO=B.EMPNO
where B.EMPNO is null
UNION ALL
select B.EMPNO
from tableA A right outer join tableB B on A.EMPNO=B.EMPNO
where A.EMPNO is null
-- 다른 방법으로 (A, B 테이블에 서로 없는것을 동시에)
select isnull(A.EMPNO,B.EMPNO)
from tableA A full outer join tableB B on A.EMPNO=B.EMPNO
where B.EMPNO is null or A.EMPNO is null