Menu

#1653 Wildcards do not function when referenced with a column name within a CONCAT

version 2.5.x
closed-invalid
None
5
2022-06-08
2022-06-08
hardwickj
No

With the given data contained in a text (csv) table:

id,last_name,first_name,middle_name,gender
1114920261,THACKER,RICHARD,RANDALL,M

And trying the following query:

SELECT * FROM "provider" p
WHERE UPPER('Thacker') LIKE CONCAT('%', "last_name", '%')
AND UPPER('Richard') LIKE CONCAT('%', "first_name", '%')

I get the expected result returned, but trying the following very similar query:

SELECT * FROM "provider" p
WHERE UPPER('Thacker') LIKE CONCAT('%', "last_name", '%')
AND UPPER('R') LIKE CONCAT('%', "first_name", '%')

...it returns nothing. The '%' wildcards surrounding the column name should allow for searching by any sequence of characters that are contained within the given name, but it appears to be functioning as an exact match only.

Discussion

  • hardwickj

    hardwickj - 2022-06-08

    Ugh nevermind....just realized I had the like reversed. Feel free to close!

     

    Last edit: hardwickj 2022-06-08
  • Fred Toussi

    Fred Toussi - 2022-06-08

    In case people wonder what was intended, it is usually something like

    SELECT * FROM "provider" p
    WHERE UPPER("last_name") LIKE CONCAT('%', UPPER('Thacker'), '%')
    
     
  • Fred Toussi

    Fred Toussi - 2022-06-08
    • status: open --> closed-invalid
    • assigned_to: Fred Toussi
     

Log in to post a comment.

Auth0 Logo