2010-05-18 5 views
0

나는 sqlite에 대한 쿼리를 수행하려고합니다. 프로필 ID와 연결되지 않은 서버의 서버 ID를 검색하려고합니다 (프로필 ID 있음). 테이블 serpro는 테이블 사이의 n : n 관계를 나타냅니다.쿼리를 수행하는 Sqlite 실패

Select server._id, server.server 
from server where server._id != (SELECT server._id FROM server 
INNER JOIN serpro ON server._id = serpro._ids 
INNER JOIN profile ON profile._id = serpro._idp 
where profile._id=" + idProfile; 

그리고 이러한 테이블 생성 문장은 다음과 같습니다 :

이 내 쿼리입니다 (분명히 잘못된 것입니다)

create table server (_id integer primary key autoincrement,ip string not null, port string not null, server string not null); 

create table profile (_id integer primary key autoincrement, profile string not null); 

create table serpro (_ids integer not null, _idp integer not null, PRIMARY KEY (_ids, _idp), CONSTRAINT fk_idsps FOREIGN KEY (_ids) REFERENCES server(_id) ON DELETE CASCADE, CONSTRAINT fk_idspp FOREIGN KEY (_idp) REFERENCES server(_id) ON DELETE CASCADE); 

여러분의 도움에 감사드립니다!

+0

어떤 오류 메시지가 나타납니다? – jabbie

+0

쿼리 작성은 SQL 삽입에 취약합니다. –

답변

1

난 그냥 당신이 하위 쿼리를 닫는 것을 잊어 버리고 있다고 말하고 싶을 것입니다. a)를 검색어 끝에 추가하십시오.

"Select server._id, server.server from server where server._id != " + 
    " (SELECT server._id FROM server INNER JOIN serpro ON server._id = serpro._ids " + 
    " INNER JOIN profile ON profile._id = serpro._idp " + 
    " where profile._id=" + idProfile + ")"; 
+0

당신 말이 맞아요. 고맙습니다 ! – fxi

관련 문제