0
 delete N.* from Tbl_Nodes N, Data_Tree DT WHERE N.Part = DT.Part

for this command I am getting following error.

System.Data.SQLite.SQLiteException: SQLite error near "N": syntax error

Above command works fine for MSAccess.

Is there any alternative to use table shortcut in Sqlite?

1
  • That's some rather non-standard SQL. What does WHERE N.Part mean, and how are Tbl_Nodes and Data_Tree correlated? Commented Nov 18, 2011 at 10:40

3 Answers 3

4

The DELETE statement operates on a single table and does not use a table alias. Therefore, your FROM clause must read FROM Tbl_Nodes.

You're probably looking for:

 delete from Tbl_Nodes WHERE Part IN (SELECT Part FROM Data_Tree)

Note that this will remove all nodes from Tbl_Nodes that have a corresponding Part value in Data_Tree but does not remove any records from Data_Tree itself.

While SQL varies somewhat among vendors, as a general principle it's a mistake to learn SQL from MS Access and try to apply it to other products. MS Access features some very non-standard constructions.

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

2 Comments

+1 for the only solution so far that even stands a chance of being correct (as opposed to a syntax error!) SQLite sticks much closer to the SQL standard in much of its syntax than most databases.
the actual alias syntax table AS alias works with DELETE. It's just when you've forgotten more compatible SQL syntax and you do table alias where it fails on DELETE. Weirdly, it does work in SELECTs.
1

Using an alias for the table?

FROM table AS t1

Comments

-1

You're missing a bit of your SQL statement there I guess but does it not work if you just say:

delete N from Tbl_Nodes N, Data_tree DT WHERE...(rest of statement)

I've just removed the .*

1 Comment

From what I find on the sqlite site it seems that doing deletes against joins as you can in other DB products is not supported. The Larry Lustig answer should work for you though.

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.