Jump to content

Passing the SQL LIKE Wildcard Into ExecuteSQL


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

Recommended Posts

I'm attempting to do a search for a value that was entered by a user. They want to be able to enter in part of a project number and have the system look for it. I understand the LIKE operator and I can get it to work if I pass the argument of something like %12345% but I want to pass in something that looks like the following: wildcard plus value entered by user plus wildcard. 

I've tried the following (let me try this again with the right code):

Let     (
    [
    project_id = "%" & d_tmd_tmh::zd_time_dtl_prj_num & "%" ; 
    SQL = ExecuteSQL    ( 
                    "
                    SELECT a.\"__project_id\"
                    FROM \"d_prj\" a
                    WHERE a.\"zd_prj_number\" LIKE ?
                    "
                    ; "|" ; ¶  ; 
                    project_id
                    )
    ] ; 

    SQL

    )

I'm not getting an error. I'm just not getting any results. When I manually substitute the same value I am testing by changing it to this:

Let     (
    [
    project_id = "%12345%" ; 
    SQL = ExecuteSQL    ( 
                    "
                    SELECT a.\"__project_id\"
                    FROM \"d_prj\" a
                    WHERE a.\"zd_prj_number\" LIKE ?
                    "
                    ; "|" ; ¶  ; 
                    project_id
                    )
    ] ; 

    project_id

    )

It works.

Any pointers in the right direction would be appreciated.

 

Never mind...

I reran things and it now seems to be working. 

Edited by oakbridge
Posted wrong block of code
Link to comment
Share on other sites

Yes, this is the FQL forum. I just wanted to remind you that FileMaker has some great 'wildcards' for finds.

http://help.filemaker.com/app/answers/detail/a_id/13715/~/refining-find-requests-in-filemaker-pro-using-find-operators

Enter Find mode
Set Field ( d_prj::__project_id ; "*" & d_tmd_tmh::zd_time_dtl_prj_num & "*" )
Perform Find

If nothing else, it gives you a double-check if the query seems to return ? or empty.

beverly

Link to comment
Share on other sites

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