android.database.sqlite.SQLiteException: no such column: ۱۵۳۶۱۹۸۶۸۴۰۰۸۵۴۲۵۴۱ - android

all.
I've found in bugsense for Android application this exeception:
android.database.sqlite.SQLiteException: no such column: ۱۵۳۶۱۹۸۶۸۴۰۰۸۵۴۲۵۴۱ (code 1): , while compiling:
SELECT * FROM by_istin_android_xcore_source_DataSourceRequestEntity WHERE (_id = -۱۵۳۶۱۹۸۶۸۴۰۰
Seems like try to select with filter by arabic number.
Someone see it before?

If _id is a numeric column, you must change your code to generate numbers with ASCII digits.
If _id contains strings, you must change your code to 'quote' the string.

Related

No such column error on selection value

This is the message from LogCat:
no such column: dkbdxfywpbkb (code 1): , while compiling: SELECT meetup_event_id FROM events WHERE meetup_event_id = dkbdxfywpbkb
Why is it trying to find a column called "dkbdxfywpbkb" when the selection argument is "....WHERE meetup_event_id = dkbdxfywpbkb"
I have checked that column "meetup_event_id" exists and is of type text.
Notes:
This query works fine except when the value(in this case "dkbdxfywpbkb") I am searching for is a piece of text rather than a number.
The value(in this case "dkbdxfywpbkb") I am searching for is from the Meetup API and not generated by my app.
I think you need single quotes. You want a string constant:
SELECT meetup_event_id
FROM events
WHERE meetup_event_id = 'dkbdxfywpbkb';
Without the quotes, SQLite thinks the string value is an identifier (numbers are treated differently from strings in this respect).

Why can't I perform a simple count in a subquery?

I'm trying to write a simple query that fetches all the columns of a specific table, but also adds a count of rows from a related table.
Here is the query:
SELECT
todos.*,
(SELECT COUNT(assets.*) FROM assets WHERE assets.parent_id = todos._id) AS asset_count
FROM todos
Here is the error:
Caused by: android.database.sqlite.SQLiteException: near "*": syntax error (code 1): , while compiling: SELECT todos.*, (SELECT COUNT(assets.*) FROM assets WHERE assets.parent_id = todos._id) AS asset_count FROM todos
try replace COUNT(assets.*) for COUNT(*) or COUNT(assets._id)
my second suggestion, try running the inside select like a single one
SELECT COUNT(*) FROM assets WHERE assets.parent_id = 1 <-- any _id you have

SQLite exception in LIKE query

I've got search query "aa bb" and also there is "aa bb cc" row in table. So my sql query should return that row. This is how I do:
select * from company
where
(ASCII_NAME like %'aa'%
and ASCII_NAME like %'bb'%)
and CITY_ID=0 and parent=-1;
But my log says:
android.database.sqlite.SQLiteException: near "%": syntax error (code
1): , while compiling: select * from company where (ASCII_NAME like
%'aa'% and ASCII_NAME like %'bb'%) and
CITY_ID=0 and parent=-1
What is wrong?
Your syntax is wrong
select * from company
where
(ASCII_NAME like '%aa%'
and ASCII_NAME like '%bb%')
and CITY_ID=0 and parent=-1;
Include % sign in single quotes.
Like:
select emp_name from employee where emp_name like '%s%';

Android Sqlite: android.database.sqlite.SQLiteException: aggregate functions are not allowed in the GROUP BY clause

Having a weird issue here where a query executes just fine in Sqlite DB Browser on my desktop - results exactly as expected - but throws an exception when executing a Cursor in Android (4.4.2). I'm new to both Android and Sqlite so maybe there's a "gotcha" I haven't discovered yet.
Simple query:
select
max(_id) as '_id',
max(envid) as 'envid',
max(action) as 'action',
max(title) as 'title',
max(cast(version as INTEGER)) as 'version',
max(layout) as 'layout'
from template
where direction = 'return'
group by title
Exception:
E/AndroidRuntime(20731): Caused by:
android.database.sqlite.SQLiteException: aggregate functions are not
allowed in the GROUP BY clause (code 1): , while compiling: select
max(_id) as '_id', max(envid) as 'envid', max(action) as 'action',
max(title) as 'title', max(cast(version as INTEGER)) as 'version',
max(layout) as 'layout' from template where direction = 'return' group
by title
I'd expect to see that if I put an aggregate function in the group by clause...but I haven't.
This fixed it - which is all I really needed (see comment from Rohit5k2 above.)
select _id, envid, action, title, max(cast(version as INTEGER)) as 'version', layout from template where direction = 'return' group by title

SQL Syntax Error Android

I am getting an SQL syntax error but I'm not quite sure why. This is the error code I am obtaining;
android.database.sqlite.SQLiteException: near "GCSE": syntax error (code 1): , while compiling: SELECT foreign_word,english_meaning,correct FROM vocab_words WHERE name = AQA GCSE Spanish Higher
Any suggestions to fix this - I don't know what the error is?
when the column's data type is string, its value should be wrapped with single quote.
SELECT foreign_word,english_meaning,correct
FROM vocab_words
WHERE name = 'AQA GCSE Spanish Higher'

Categories

Resources