00 Votes

SQLite: Search for unequal Value

Question by Guest | 2016-02-08 at 15:36

I would like to read out the data records from my table / database which are not containing a specific value in a specific column.

So, I need something like an unequal, unlike, distinct or disparate comparison with a defined value. In other database systems, I have used the comparison operator != for that, but that seems not to work in SQLite. However, the operators =, < and > are working, but I do not need them at this point.

How should the statement look like to make it work?

ReplyPositiveNegative
0Best Answer0 Votes

In SQLite, you have to use the operator <> for inequality. Here is an example for an integer and a string comparison:

SELECT id FROM tab WHERE weight <> 100;

SELECT id FROM tab WHERE firstname <> 'Peter';

Using the first statement, we get all our records where the column "weight" is not 100, the second statement returns all records, where the column "firstname" is not "Peter".

As you can see, strings have to be enclosed with apostrophes, and you do not have to care about that with numbers.
2016-02-09 at 18:17

ReplyPositive Negative
Reply

Related Topics

The Askingbox Search

Info | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.