Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rawQuery(query, selectionArgs)

Tags:

android

sqlite

I want to use select query for retrieving data from table. I have found, rawQuery(query, selectionArgs) method of SQLiteDatabase class to retrieve data. But I don't know how the query and selectionArgs should be passed to rawQuery method?

like image 979
sree_iphonedev Avatar asked May 15 '12 09:05

sree_iphonedev


People also ask

What is the difference between RawQuery and query in android?

RawQuery is for people who understand SQL and aren't afraid of it, query is for people who don't.

Which is the return type of DB RawQuery () function?

RawQuery methods must return a non-void type. If you want to execute a raw query that does not return any value, use RoomDatabase#query methods.

What is cursor moveToFirst?

Cursor is an object that can iterate on the result rows of your query. Cursor can moves to each row. . moveToFirst() method move it to the first row of result table.

What is raw query in Sequelize?

As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the sequelize. query method. By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).


1 Answers

rawQuery("SELECT id, name FROM people WHERE name = ? AND id = ?", new String[] {"David", "2"}); 

You pass a string array with an equal number of elements as you have "?"

like image 64
Rawkode Avatar answered Sep 23 '22 20:09

Rawkode