DreamsOfHummus
DreamsOfHummus

Reputation: 745

SQL Statement giving error

I am using SQLite on Android and am getting a problem when running this command :

UPDATE vocab_words SET correct = 5 
WHERE
    name = 'AQA GCSE Spanish Higher',
    foreign_word = 'campo, el',
    english_meaning = 'field, the'

What is the problem here? Thanks in advance.

Upvotes: 1

Views: 84

Answers (3)

Piyas De
Piyas De

Reputation: 1764

From initial viewing your post the update statement should be -

UPDATE vocab_words SET correct = 5 WHERE name = 'AQA GCSE Spanish Higher' and foreign_word = 'campo, el' and english_meaning = 'field, the'

Upvotes: 0

Pradeep Simha
Pradeep Simha

Reputation: 18123

Your SQL query has a syntax error.Change your query from:

UPDATE vocab_words SET correct = 5 WHERE name = 'AQA GCSE Spanish Higher', foreign_word = 'campo, el', english_meaning = 'field, the'

to:

UPDATE vocab_words SET correct = 5 WHERE name = 'AQA GCSE Spanish Higher'AND foreign_word = 'campo, el'AND english_meaning = 'field, the'

Also I suggest you to read basics of SQL using some tutorials. This is one of the basic error.

Upvotes: 5

Subhrajyoti Majumder
Subhrajyoti Majumder

Reputation: 41200

Combine two or more simple conditions by using the AND not with comma(,).

UPDATE vocab_words SET correct = 5 WHERE name = 'AQA GCSE Spanish Higher', foreign_word = 'campo, el', english_meaning = 'field, the'

Replace with

UPDATE vocab_words SET correct = 5 WHERE name = 'AQA GCSE Spanish Higher' AND foreign_word = 'campo, el' AND english_meaning = 'field, the'

Upvotes: 3

Related Questions