Search code examples
iosipadsqlite

The query is not working?


In my application I use sqlite as a Backing store.For my use I create Two tables for Surgeon and Schedule with surgeon having columns Name(VARCHAR),id(int) and Schedule having id(int),Surgeon(int),Values(VARCHAR).

The Surgeon column in Schedule table is pointing to the id column in Surgeon table. I use The Below query to select values from the Schedule table for the Surgeon with id=1

SELECT Schedule.Values,Name from Schedule,Surgeon where Schedule.Surgeon==Surgeon.id and Surgeon.id=2

But I got error as below

SQLiteManager: Likely SQL syntax error: SELECT Schedule.Values,Name from Schedule,Surgeon where Schedule.Surgeon==Surgeon.id and Surgeon.id=2 [ near "Values": syntax error ]

I don't know where it went wrong, I have't used the database before so forgive me if the question is much basic


Solution

  • You have named one of the columns in Schedule  as values Change it to something else that is not a key word for sqlite. you should not use key string to name the column  First you have to take a look at the keys in sqlite