Creating desktop or client-server database solutions?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Tue Sep 15, 2015 2:47 am
Seems like this should work but alas... no-joy. I'm trying to select all of theNames where theType does not match the string. It seems that SQLite doesn't like the <> because it ignores it. What is the syntax to accomplish this?
Code: Select all
put "SELECT theName FROM MyNames WHERE theType <> 'Production' OR theType <> 'Device'" into tSQLStatement
Tom
MacBook Pro OS Mojave 10.14
-
Simon
- VIP Livecode Opensource Backer

- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
Post
by Simon » Tue Sep 15, 2015 3:59 am
Hi quailcreek,
Did you try "!="
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Tue Sep 15, 2015 5:21 am
Yep, I tried that Simon. It gets ignored too. Seems like it should throw an error but it doesn't
Tom
MacBook Pro OS Mojave 10.14
-
SparkOut
- Posts: 2949
- Joined: Sun Sep 23, 2007 4:58 pm
Post
by SparkOut » Tue Sep 15, 2015 7:18 am
Are you sure the <> is being ignored?
It looks like your query will return all results because all of the records will be either not equal to production or not equal to device. (Everything)
Try changing OR to AND in the query.
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Tue Sep 15, 2015 6:23 pm
Hi Sparkout,
That did it. Changed OR to AND and now both <> and != work. Seems somehow counter intuitive. I would have thought that OR meant the string could contain either Production or Device and AND meant the string needs to contain both. I guess the way SQLite does the boolean is exclude (Production AND Device). Hmm... looks like I explained it to myself.
Thanks, Sparkout.
Tom
MacBook Pro OS Mojave 10.14
-
SparkOut
- Posts: 2949
- Joined: Sun Sep 23, 2007 4:58 pm
Post
by SparkOut » Tue Sep 15, 2015 9:44 pm
This is actually normal boolean resolution. It might look counterintuitive at first glance but really it is quite logical.
What you were asking the query to match is where the first condition was true (theType <> 'Production') OR the second condition was true (theType <> 'Device') . If theType is Production then the first condition is false so the second condition will be checked. If theType is Production then it obviously is not Device so the overall query will resolve true and return the record, and vice versa for theType being Device. Thus every record would be returned.
-
quailcreek
- Posts: 746
- Joined: Sun Feb 04, 2007 11:01 pm
Post
by quailcreek » Tue Sep 15, 2015 9:57 pm
Thanks, Sparkout. It works a little differently then I thought but it makes sense.
Tom
MacBook Pro OS Mojave 10.14