Reputation: 5960
"SELECT * FROM locations
JOIN section_has_location ON locations.location_id = section_has_location.location_id
WHERE section_has_location.chapter_id =2
AND section_has_location.section_id=2"
I get the error:
SQLError: 'Error #3132: Data type mismatch.', details:'could not convert text value to numeric value.', operation:'execute', detailID:'2300'
These are the tables:
CREATE TABLE locations (
location_id INTEGER,
name TEXT,
mask_id TEXT,
x REAL,
y REAL,
content TEXT,
image_url TEXT,
type TEXT
);
CREATE TABLE section_has_location (
chapter_id INTEGER,
section_id INTEGER,
location_id INTEGER
);
How do I fix the query as to not cause the error?
update: I exported all the data, and imported into a new clean database. This seems to have solved that error.
Upvotes: 2
Views: 11349
Reputation: 1
I know this is an old question, but I found a fresh answer today. I was getting exactly the same error and it turned out that the record I was trying to update had an integer column which contained a string value '0' instead of an integer 0. Even though I wasn't trying to set that field, it caused this error -- and the error went away when I fixed that column's value manually.
The reason that field contained a string was that the DDL used to create the table defined the column as an integer but had a DEFAULT '0' clause instead of DEFAULT 0. That meant that newly inserted rows got the string value put into the column.
Upvotes: 0
Reputation: 5284
I just took your code, created the tables and ran the query and it works fine.
Im guessing what you have done is maybe edited the type of one of the columns but the table hasn't been updated, try sp_help tablenamehere or look in object explorer if you are using management studio and check what the datatype is of your columns, or if you can it may be easier to just drop both tables and recreate them
Upvotes: 2