15

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.

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

1 Answer 1

17

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi, thanks for the post. You were right, that sorted the first syntax error. Also WHERE ROWID should have been WHERE trackId, and SELECT ROWID should have been SELECT track.ROWID. The script now seems to be working. Thanks for your help! :)
DELETE FROM tblRecipe WHERE categoryID in ( SELECT categoryID FROM tblSubCategories INNER JOIN tblRecipe ON (tblSubCategories.categoryID = tblRecipe.categoryID) WHERE tblRecipe.categoryID = 9;
whnat if you had 2 columns say rowid and something else
@PirateApp: I don't understand your question. I suggest posting a new question with details of your specific query and problem.
As I suggested, you should ask a new question. (Although that question has probably already been asked)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.