开发者

Sqlite failure doing a Query

Im trying to do a query on sqlite. I want to retrieve the server id of the servers that are not associated with a profile id (i have the id of the profile). The table serpro represents the n:n relationship between the tables.

This is my query (apparently it is wrong):

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;

And these are the table creation sentences:

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 n开发者_如何学Pythonot 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);

Thank you for your help!


Just doing a cursory look at it I would say you are forgetting to close the sub query. Add a ) to the end of your query

  "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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜