This topic is locked
[SOLVED]

 Where do I put the % in this query

7/10/2020 6:13:47 AM
PHPRunner General questions
P
PaulM author

How do I finish this query to add the %
and (concat(L_first_name,' ',L_last_name) like ( select RS_search from Resume_Search))

L
lewis 7/10/2020



How do I finish this query to add the %
and (concat(L_first_name,' ',L_last_name) like ( select RS_search from Resume_Search))


Offhand, you might try using IN (and no "%") instead of LIKE. It appears you are comparing against a set and not a single value.

P
PaulM author 7/10/2020



Offhand, you might try using IN (and no "%") instead of LIKE. It appears you are comparing against a set and not a single value.


Thanks but it has to be like as the entry in Resume_Search might not be the full name so I need the wildcat search

L
lewis 7/10/2020



Thanks but it has to be like as the entry in Resume_Search might not be the full name so I need the wildcat search


We need more to go on as we can only guess what you are trying to do and what data you are working with.

  1. What are the typical results of "(select RS_search from Resume_Search)"?
  2. Will it return only one value or more than one?
  3. Where do you intend to need a wildcard -- beginning, end, middle, all of the above?
  4. Can you give some examples? We don't know what the data is that you are trying to accommodate or compare.

P
PaulM author 7/10/2020



We need more to go on as we can only guess what you are trying to do and what data you are working with.

  1. What are the typical results of "(select RS_search from Resume_Search)"?
  2. Will it return only one value or more than one?
  3. Where do you intend to need a wildcard -- beginning, end, middle, all of the above?
  4. Can you give some examples? We don't know what the data is that you are trying to accommodate or compare.


Resume_search will return the first and last name but also may contain just the first or last name or a part of a name

it will only return one row
Because I'm using Dashboards, a search for a person isn't persistent when the dashboard is refreshed via an edit in the detail tables and I don't want to have to search everytime a table is edited. So what I'm doing is trying to build my own search that writes to a table and the loads that on refresh.

L
lewis 7/10/2020

For specific syntax we need to know what database you are using. Here is what works in a PostgreSQL test.

AND ( CONCAT(L_first_name,' ',L_last_name) LIKE ( CONCAT('%', (SELECT RS_search FROM Resume_Search), '%') ) )


If you need a wildcard in the middle somewhere that adds complexity.

If the SELECT clause only gives first, last, or partial names you may get multiple matches. More wildcards will increase that possibility. Wildcards in the middle can make it problematic.

P
PaulM author 7/11/2020



For specific syntax we need to know what database you are using. Here is what works in a PostgreSQL test.

AND ( CONCAT(L_first_name,' ',L_last_name) LIKE ( CONCAT('%', (SELECT RS_search FROM Resume_Search), '%') ) )


If you need a wildcard in the middle somewhere that adds complexity.

If the SELECT clause only gives first, last, or partial names you may get multiple matches. More wildcards will increase that possibility. Wildcards in the middle can make it problematic.


Thank you, I'm using a MySql database
PERFECT - Thank you
and (concat(L_first_name,' ',L_last_name) like (concat('%',(select RS_search from Resume_Search),'%')))