Select the first word of a text string, use in query LIKE operator?
Greetings
I have a text string containing the last names of a people (5000+ in DB), but in this case, alias names follow delimited by spaces. French last names have "dit" (Smith dit Smythe dit Smitt) names.
I would like to retrieve only the first (last) name to use in a dynamic query.
so,
<cfquery name="trim_last_name" datasource="#Request.BaseDSN#">
SELECT ged_lastname
FROM ged_main
</cfquery>
<cfset clean_last_name = listfirst(trim_last_name.ged_lastname, " ")>
<cfoutput query="trim_last_name">
<cfquery name="match_carignan_name" datasource="#Request.BaseDSN#">
SELECT *
FROM carignan_main, ged_main
WHERE carignan_lname LIKE #clean_last_name#
AND carignan_fname LIKE ged_firstname
ORDER BY clean_last_name ASC</cfquery>
</cfoutput>
This is wrong, of course, and the result shows only one last name, which actually does not have additional "dit" last names.
|
There is more than one way to do this- using SQL alone, or split the burden?
Thanks in advance for your time
Norman B.
