Justin Close Posted November 12, 2013 Posted November 12, 2013 I ran into an odd problem today with ExecuteSQL(). I was trying to run a query that would count things that were NOT set, i.e.: ExecuteSQL ( "SELECT COUNT ( ID_pk ) FROM Updates WHERE ID_pk = ? AND Replaced ≠ ? " ; "" ; "" ; ParentID ; 1 ) Each parent could have a number of updates, but we only want one active at a time; so if the Update is marked as 'Replaced' then it is no longer active. So my query above was returning a dreaded "?". However, if I ran THIS query: ExecuteSQL ( "SELECT COUNT ( ID_pk ) FROM Updates WHERE ID_pk = ? AND Replaced = ? " ; "" ; "" ; ParentID ; "" ) I got the correct result. So it apparently doesn't want to consider a NULL value as a 'not equal to 1'? And why didn't it just report 0? Why the question mark? I will probably define an auto-enter calc to set it to 0 in the first place, but it really seems like this query should work without that having to be defined as something non-empty. Thanks, J
Justin Close Posted November 12, 2013 Author Posted November 12, 2013 Doh!! Apparently it doesn't recognize the "≠" operator. When I replaced it with "<>" it worked fine.
comment Posted November 12, 2013 Posted November 12, 2013 I don't think SQL recognizes the ≠ operator; try using <> instead. That would account for the question mark. Re null values, they have their own operators: IS NULL and IS NOT NULL. See here for a better explanation: http://www.w3schools.com/sql/sql_null_values.asp http://www.xaprb.com/blog/2006/05/18/why-null-never-compares-false-to-anything-in-sql/ 1
LaRetta Posted November 13, 2013 Posted November 13, 2013 Thank you for the links. The first produces a 404 error until I remove the colon (or is that a semi-colon?) from the end.
Justin Close Posted November 13, 2013 Author Posted November 13, 2013 Thanks for the links, Comment. Very interesting behavior. Good information to know about.
Recommended Posts
This topic is 4084 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now