Jump to content
Server Maintenance This Week. ×

SQL SELECT with WHERE clause uses a checkbox field


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

Recommended Posts

Hey guys, I was wondering if anyone knew the answer to this problem. I'm trying to generate a value list based on a checkbox field in another table. I know how to achieve the value list portion of it, as this works when I change the checkbox field to a text field with a single value. But I can't seem to avoid getting the "?" when I use a checkbox field for the WHERE criteria. Any ideas? 
 
Let([
 
      ~sql = " SELECT Field1 FROM Table1 WHERE CheckboxFieldValue = ?"
 
      ];
 
      ExecuteSQL ( ~sql ; "" ; "¶" ;  "Value" )
 
      )
Link to comment
Share on other sites

remember a check box field is a normal field with return separated text, so the if the checkbox field had 

 

cat¶dog¶mouse all selected and you are trying to find dog you may need to use a more loose search because the the contents doesn't equal the string.

 

or you may need to create a Field that uses pattern match such as isDOG and results to a boolean. using that in your sql.

Link to comment
Share on other sites

i was thinking of the LIKE operator

 

http://www.w3schools.com/sql/sql_like.asp

 

-

If your searching for DOG via SQL create a field that is: PatternCount ( table::CheckBoxFieldValue ; "dog" ) this field will evaluate to 1 or 0 use it in your field

 

Let([
 
      ~sql = " SELECT Field1 FROM Table1 WHERE isDOG = ?"
 
      ];
 
      ExecuteSQL ( ~sql ; "" ; "¶" ;  "1" )
 
      )
Link to comment
Share on other sites

I'm going to work on the second option now, but the query worked when using the "LIKE" operator. Just one quick question, what if I wanted to use a global variable as a match for the CheckboxFieldValue? Meaning, how do I frame the WHERE Value and the % operator when said Value is a global variable? By the way, thanks so far for the help.

 

 

Let([
 
      ~sql = " SELECT Field1 FROM Table1 WHERE CheckboxFieldValue = ?"
 
      ];
 
      ExecuteSQL ( ~sql ; "" ; "¶" ;  $$Value% )
 
      )
 
 
Link to comment
Share on other sites

This topic is 4177 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.