I am building a "related resources" page that searches our library for papers having to do with a specific aircraft. If a visitor is researching the XV-1, I want to find all papers containing the designation "XV-1" in the title. But I don't want to find any papers on the XV-15. The aircraft designation is a ColdFusion variable, and we are using MySQL.
What I am using now:
WHERE title LIKE <cfqueryparam cfsqltype="cf_sql_varchar" value="%#trim(aircraftDesignation)#%" />
This returns "The XV-1's Rotor System" as expected, but also returns "Using RotCFD to Predict Isolated XV-15 Rotor Performance" which we don't want.
I think that if I could query on the aircraft designation, without allowing for any numeric characters immediately afterwards, but allowing for other characters such as apostrophe or comma, that might work. However, I tried
'%#trim(aircraftDesignation)#[^0-9]%'
and
'%#trim(aircraftDesignation)#[!0-9]%'
neither of which return anything at all. I would greatly appreciate any assistance or nudges in the right direction, if this is at all possible! Thank you very much for your advice.
UPDATE: I have done a poor job explaining. My apologies! We do have a field for Aircraft Designation. The related resources query runs only when a visitor lands on a specific page. For example, if he or she lands on the XV-1 page, Aircraft Designation will have be assigned a value of "XV-1." The query for related resources happens automatically based on that assigned Aircraft Designation (different per page). No user input is taken.
My effort to not include numbers after "XV-1" was an attempt to prevent papers on the XV-15 from showing on the XV-1 page. Papers on the XV-15 would show on the XV-15 page, since "XV-15" is the Aircraft Designation. But papers on the XV-167 (if there was such a thing) would not show on the XV-15 page.
I tagged this as ColdFusion because Aircraft Designation is a CF variable being used in the query. My attempts to use SQL (and my research into using REGEXP are either failing because I seem to be not using the variable correctly. Or in the case of REGEXP, unable to use a variable in conjunction with a regular expression.
I hope this helps clarify! Thank you all so much for your help.
ANOTHER UPDATE: Using REGEXP like this:
WHERE title REGEXP '#trim(aircraftDesignation)#[^0-9]'
is working fine so far! A paper with "XV-1" in the title, plus the "XV-1's" paper, are both showing. But the XV-15 papers are not. All of the other searches I have spot-checked seem to be working as expected.
The full text searching is a great option though and I will definitely look into it further. Thanks everybody for your help and suggestions! I really appreciate it.