database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
ㆍSybase
MS-SQL
DB2
Cache
CUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
Sybase Q&A 3939 게시물 읽기
No. 3939
update문 질문좀 드리겠습니다..ㅠㅠ
작성자
손건영(skyjws)
작성일
2009-11-13 11:00
조회수
7,476

select a.JAEHAEJA_RGNO ,

      ( select e.JAEHAEJA_RGNO

           from nis..BAA130MT d

          inner join nis..BAA010MT e

             on e.WONBU_NO = d.WONBU_NO

          where d.RGNO     = a.JAEHAEJA_RGNO

       )                                    -- BAA010MT(업데이트할 주민번호 )

 from ris..BGH020MT a

 where exists ( select 1

                  from nis..BAA130MT b

                 where b.RGNO   = a.JAEHAEJA_RGNO

                 group by a.JAEHAEJA_RGNO

                having count(*) = 1

              )

   and exists ( select 1

                  from nis..BAA130MT d

                 inner join nis..BAA010MT e

                    on e.WONBU_NO = d.WONBU_NO

                  left outer join nis..BAA010MT c

                    on c.JAEHAEJA_RGNO = a.JAEHAEJA_RGNO

                 where c.JAEHAEJA_RGNO IS NULL    --BAA010MT에 없는 주민번호

                   and d.RGNO     = a.JAEHAEJA_RGNO

              )

이  select  문을 update문으로 고칠려구 하는데요...ㅠㅠ 왜 안되는지 잘모르겠어요..ㅠㅠ 


update ris..BGH020MT a

set a.JAEHAEJA_RGNO = ( select e.JAEHAEJA_RGNO

                          from nis..BAA130MT d

                         inner join nis..BAA010MT e

                            on e.WONBU_NO = d.WONBU_NO

                         where d.RGNO     = a.JAEHAEJA_RGNO

                       ) 

 where exists ( select 1

                  from nis..BAA130MT b

                 where b.RGNO   = a.JAEHAEJA_RGNO

                 group by a.JAEHAEJA_RGNO

                having count(*) = 1

              )

   and exists ( select 1

                  from nis..BAA130MT d

                 inner join nis..BAA010MT e

                    on e.WONBU_NO = d.WONBU_NO

                  left outer join nis..BAA010MT c

                    on c.JAEHAEJA_RGNO = a.JAEHAEJA_RGNO

                 where c.JAEHAEJA_RGNO IS NULL    --BAA010MT에 없는 주민번호

                   and d.RGNO     = a.JAEHAEJA_RGNO

              )

이런식으로 고쳤는데 이러가 나네요...ㅠㅠ 


에러 메시지는 

Server Message:  Number  102, Severity  15

Server 'SEOUL01_DEV', Line 1:

Incorrect syntax near 'a'.

Server Message:  Number  102, Severity  15

Server 'SEOUL01_DEV', Line 2:

Incorrect syntax near '='.

Server Message:  Number  107, Severity  15

Server 'SEOUL01_DEV', Line 3:

The column prefix '.e.' does not match with a table name or alias name used in the query. Either the table is not specified in the FROM clause or it has a correlation name which must be used instead.

Server Message:  Number  156, Severity  15

Server 'SEOUL01_DEV', Line 13:

Incorrect syntax near the keyword 'and'.

Server Message:  Number  107, Severity  15

Server 'SEOUL01_DEV', Line 17:

The column prefix 'a' does not match with a table name or alias name used in the query. Either the table is not specified in the FROM clause or it has a correlation name which must be used instead.

Server Message:  Number  107, Severity  15

Server 'SEOUL01_DEV', Line 19:

The column prefix 'a' does not match with a table name or alias name used in the query. Either the table is not specified in the FROM clause or it has a correlation name which must be used instead.

이고구요 잘 부탁드립니다..ㅠㅠ


이 글에 대한 댓글이 총 1건 있습니다.

update 테이블 a set

    a.col1 = b.col1 ,

    a.col2 = b.col2

from 테이블 b

where a.col = b.col

의 형식을 응용해서 작성해 보시죠.

최승은(antichoi)님이 2011-04-04 15:49에 작성한 댓글입니다.
[Top]
No.
제목
작성자
작성일
조회
3942인라인뷰 변형 부분에 대해서 [2]
sybase
2009-11-17
6755
3941sysindexes로 테이블 건수를 출력하려고 하는대 없는 테이블이 있습니다. [2]
이광호
2009-11-17
7032
3940db 2개가 있는데 한쪽에서만 정상 작동합니다. 도와주세요~ [1]
김태호
2009-11-13
6535
3939update문 질문좀 드리겠습니다..ㅠㅠ [1]
손건영
2009-11-13
7476
3938사이베이스중 text필드의 크기? [1]
승우
2009-11-09
7129
3937제발 도와주세요 view 카운트가 안됩니다. text 필드와 함께 만든 뷰.... [2]
박찬구
2009-11-06
7328
3936MSTR을 사용할 경우 인덱스 사용.. [1]
에모토
2009-11-04
6478
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.022초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다