I want to access records from SQLite in android using rawQuery(query,arg)
. I have two columns in database one called friendsID
and 2nd called emailSenderID
.
Now If I send mail to my friend emailSenderID
-column will save my ID and friendsID
-column save my friend's ID. If I receive an email from same friend then friendsID
-column will save my ID and emailSenderID
-column will save my friend's ID.
Now, If I wanna fetch record like this:
Select * from emailTable where friendsID =fID
and emailSenderID=fID
OR emailSenderID=myID
Please guide me how I can use AND
and OR
operators for Android SQLite.
The SQLite docs explains why this is so slow: Transaction speed is limited by disk drive speed because (by default) SQLite actually waits until the data really is safely stored on the disk surface before the transaction is complete. That way, if you suddenly lose power or if your OS crashes, your data is still safe.
What is a SQLite File? A file with . sqlite extension is a lightweight SQL database file created with the SQLite software. It is a database in a file itself and implements a self-contained, full-featured, highly-reliable SQL database engine.
An operator is a reserved word or a character used primarily in an SQLite statement's WHERE clause to perform operation(s), such as comparisons and arithmetic operations. Operators are used to specify conditions in an SQLite statement and to serve as conjunctions for multiple conditions in a statement.
First, by default, multiple processes can have the same SQLite database open at the same time, and several read accesses can be satisfied in parallel. In case of writing, a single write to the database locks the database for a short time, nothing, even reading, can access the database file at all.
I guess you mean something like this: "Get me all entries from emailTable
where friendsID
is fID
and emailSenderID
is either fID
or myID
." In that case you need to group it like this:
SELECT * FROM emailTable WHERE friendsID=fID AND
(emailSenderID=fID OR
emailSenderID=myID)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With