删除具有内部联接的行?

问题描述:

我有一个带有两个表的SQLITE数据库.表A具有一个整数时间戳,另一个整数列包含一个行ID,该行ID引用表B中具有两个时间戳的行.

I have a SQLITE database with two tables. Table A has an integer timestamp and another integer column containing a row id referring to a row in table B which has two timestamps.

我想删除表A中时间戳不在表B中两个时间戳之间并且ROWID等于X的所有行.

I want to delete all rows in table A where it's timestamp does not lie between the two timestamps in table B, and the ROWID is equal to X.

这是我目前所拥有的,但是出现语法错误:

Here is what I have at the moment but I am getting a syntax error:

DELETE FROM network
WHERE ROWID in (
    SELECT ROWID 
    FROM track 
    INNER JOIN network ON (track.ROWID = network.trackId) 
    WHERE network.timestamp > track.stopTime OR network.timestamp < track.startTime 
        AND network.trackId = X

对于子选择,您没有右括号.试试这个:

You don't have a closing parenthesis for your subselect. Try this:

DELETE FROM network
WHERE ROWID in (
    SELECT ROWID 
    FROM track 
    INNER JOIN network ON (track.ROWID = network.trackId) 
    WHERE network.timestamp > track.stopTime OR network.timestamp < track.startTime 
       AND network.trackId = X
)

如果这不起作用,请尝试发布您的实际语法错误.

If that doesn't work, try posting your actual syntax error.