Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite SELECT equal to one of two values

Tags:

select

sqlite

I am trying to get the messages where the sendID is equal to one of two values. This is the statement that I have but it seems to spit out only the messages associated with the first sendID.

(SELECT * FROM messages WHERE sendID = ? AND ? ORDER BY timeStamp ASC', id1, id2)

Can anyone suggest a good method to do this?

Thanks

like image 537
Leonardo Amigoni Avatar asked Nov 16 '11 21:11

Leonardo Amigoni


People also ask

What does || mean in SQLite?

Description. The SQLite || operator allows you to concatenate 2 or more strings together.

Where with multiple conditions SQLite?

The AND operator allows the existence of multiple conditions in a SQLite statement's WHERE clause. While using AND operator, complete condition will be assumed true when all the conditions are true. For example, [condition1] AND [condition2] will be true only when both condition1 and condition2 are true.

What is wildcard in SQLite?

SQLite provides two wildcards for constructing patterns. They are percent sign % and underscore _ : The percent sign % wildcard matches any sequence of zero or more characters. The underscore _ wildcard matches any single character.


1 Answers

 WHERE sendID = ? OR sendID = ?

or

 WHERE sendID IN (?, ?)
like image 167
Larry Lustig Avatar answered Sep 19 '22 21:09

Larry Lustig