develop

오라클 LIKE 검색시에는 왜 이럴까?

파드파드 2007. 12. 4. 13:30
반응형

Select 문을 한개씩 실행해 보아라.
왜 그럴까?

with temp as
(
   select cast( '' as char(3)) as tt from dual
  union all
  select cast( '123' as char(3)) from dual
)
--select * from temp where tt like '%'
select * from temp where nvl(tt,'asdf') like '%'


with temp as
(
   select cast( '' as varchar2(3)) as tt from dual
  union all
  select cast( '123' as varchar2(3)) from dual
)
--select * from temp where tt like '%'
select * from temp where nvl(tt,'11') like '%'


with temp as
(
   select cast( '' as int) as tt from dual
  union all
  select cast( '123' as int) from dual
)
--select * from temp where tt like '%'
select * from temp where nvl(tt,1) like '%'


--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------

그렇다면 MS-SQL은 ?

with temp as
(
   select cast( '' as varchar(3)) as tt
  union all
  select cast( '123' as varchar(3))
)
select * from temp where tt like '%'
--select * from temp where isnull(tt,' ') like '%'


with temp as
(
   select cast( '' as char(3)) as tt
  union all
  select cast( '123' as char(3))
)
select * from temp where tt like '%'
--select * from temp where isnull(tt,' ') like '%'

결론은 ms sql은 상관없다는 거.

반응형