Jump to content

Field name inside of field?


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

Recommended Posts

I created a global called FIELD to hold a field name.  I want to reference this global as the field name it should find and use it like this:

 

ExecuteSQL(

"SELECT id

FROM customers

WHERE field LIKE ? "

; "" ; "" ;  "%NY%" )

 

I think I am confused.  FIELD would hold the value of 'State' in this example.  So I want it to look at the State field and find all NY states.  How do I reference a global field which references a real field please?  I have been reading bunches of examples and still can't figure this out.

 

I changed the name of the post to hopefully explain.

Link to comment
Share on other sites

And while here in case even this example doesn't help. I want same thing for the contains portion below in its variation spot. I want a a global field below as %VALUE%.  to use to find the value in the field itself.  I even tried GetFieldName to no avail.  So I don't want to reference those global fields but rather the value inside them as the field I want to reference.

Link to comment
Share on other sites

The SQL statement is just a string of text that you can construct like any other text string in FileMaker, e.g.:

"SELECT id
 FROM customers
 WHERE " & field & " LIKE ?"
Link to comment
Share on other sites

oh wow. Sometimes it's the little things

 

WHERE " & field & " LIKE ?"

 

I was not leaving a space after the where and before the like.  Thank you for the precise example which clearly showed my error.

Link to comment
Share on other sites

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