union all..like 0 1 1,072

by 지연 [2015.11.01 21:50:56]


select *

from (

select

 '1' as gubun,

title as title

from dual

union

 '2' as gubun,

title as titles

from dual

)

 where 1=1

and title like '% 음료수 %'  or  titles '% 음료수 %' 

이런식으로 하면 한단어에 두개 1,2를 다 검색할수 있는지요?

by 우리집아찌 [2015.11.02 08:36:21]
WITH T1 AS (
SELECT '1' gubun , '음료수' title FROM DUAL UNION ALL
SELECT '1' , '음료수' FROM DUAL UNION ALL
SELECT '1' , '음료수' FROM DUAL UNION ALL
SELECT '1' , '음료수' FROM DUAL UNION ALL
SELECT '1' , '음료수' FROM DUAL 
), T2 AS (
SELECT '2' gubun, '음료수' title FROM DUAL UNION ALL
SELECT '2' , '음료수' FROM DUAL UNION ALL
SELECT '2' , '음료수' FROM DUAL UNION ALL
SELECT '2' , '음료수' FROM DUAL UNION ALL
SELECT '2' , '음료수' FROM DUAL 
)

SELECT * FROM T1
UNION ALL
SELECT * FROM T2

WHERE TITLE LIKE '%' || '음료수' || '%'

 

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입