Jump to content
Server Maintenance This Week. ×

ESQL can't evaluate 'not equals'?


This topic is 3823 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

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/

  • Like 1
Link to comment
Share on other sites

This topic is 3823 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.