[SQLite] Query returns results with a SELECT statement, but DELETE throws an error. via /r/learnprogramming


[SQLite] Query returns results with a SELECT statement, but DELETE throws an error.

I'm trying to remove rows from a table when certain conditions are met.

This query:

 SELECT count(*) FROM tweets LEFT JOIN place ON tweets.place_id = place.id WHERE (tweets.place_id is NOT NULL AND place.country_code != "GB") 

Returns a result, as does the same query asking for the actual results rather than the count.

However, when I replace the select with a delete i.e.

DELETE FROM tweets LEFT JOIN place ON tweets.place_id = place.id WHERE (tweets.place_id is NOT NULL AND place.country_code != "GB") 

It returns this error:

SQL error: near "LEFT": syntax error.

The query works, so why does it give an error when I try to delete the rows?

Submitted July 13, 2017 at 01:24PM by 8richardsonj
via reddit http://ift.tt/2vhkEQp

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s