본문 바로가기

SQL/informix

연관성 없는 두개의 테이블을 조회해서 두테이블의 값을 다 출력하기


















서로다른 테이블 전부 출력하기(union all)


 select
     skip  0 first 10
      '1' gubn,  seq,  title, substr(actdate,1,10) as event_date ,
       content,   actplace,     photoseq,  real_photo , qrycnt as index_num
      FROM chiefact
      where substr(actdate,1,10) >'2010-06-24'
      union all
     SELECT '2' gubn,   a.seq,   a.title,   a.event_date ,
     a.contents as content,  a.place as actplace,      b.sys_file as photoseq,     b.real_file as real_photo, b.index_num
      FROM multimedia_data a, multimedia_file b                                
      where a.seq=b.seq
       and  a.event_date >'2010-06-24'
       and  a.nalchief_show='Y'
       and   b.index_num = 1
     order by event_date desc,
   seq desc

 

///////////////////////////////////////////////////////////////////////////////

서로다른 테이블 전부 출력하기 상세페이지 조회

SELECT seq,  title, actdate as reg_date ,                     content,                    actplace,           photoseq,       real_photo 
  FROM chiefact
 where '1' = #ddd#
  union all
SELECT  seq,   title,   reg_date ,    contents as content,  place as actplace,   ''  photoseq,   ''  real_photo 
   FROM multimedia_data
    where '2' = #ddd#

//////////////////////////////////////////////////////////////////////////////

 

 

select
 seq,  title, substr(actdate,1,10) as event_date ,  content,  actplace,  photoseq, real_photo
 FROM chiefact
 where                                                                         
 ''= seq                                                                       
     union all
 SELECT
a.seq, a.title, a.event_date , a.contents as content, a.place as actplace, b.sys_file as photoseq, b.real_file  as  real_photo
FROM multimedia_data a, multimedia_file b
where
 a.seq= b.seq
 and '546' = a.seq

 

 

 SELECT
     skip 1 first 1
      seq, title, actdate as    event_date, actplace
     from
     chiefact
     where substr(actdate,0,10) > '2010-06-24'
      union all
      SELECT
     seq,   title, event_date, place as actplace
     from
     multimedia_data
     where
     event_date >'2010-06-24'

 order by event_date desc
  , seq desc

 

테이블 자료형을 맞추고, 출력할 칼럼들을 조회