2021年5月3日星期一

What is the most standard criteria for 'partial match' in sql select queries?

I have been asked that the queries to the database be partial match.

Generally, to use partial match with LIKE we need to know which wildcard we are going to use for pattern matching, right?.

My question is: is there a 'generic' case to apply partial match without having any specific constraints?

This is an example query that I use in my project, could someone give me an example of how to do this query 'partial match' without any specific constraints?

select      a.*,      coalesce(nullif(a.aachange, '.'), nullif(a.detailref, '.') ) as var,      b.*,      c.*  from      db-dummy.data c  join db-dummy.info a on      a.record_id = c.var_id  join db-dummy.s_data b on      b.record_id = c.s_id  order by      a.g_name;  

UPDATE:

I am going to add more information about the desired output.

Let's say I have a column:

+------------+  |    Col     |  +------------+  | ABCDEFG    |  | ABCDEFGH   |  | ABCDEFGHI  |  | AB12398JKH |  +------------+  

If Where Col = 'AB', the result should be: ABCDEFG, ABCDEFGH, ABCDEFGHI, AB12398JKH

If Where Col = 'ABC' the result should be: ABCDEFG, ABCDEFGH, ABCDEFGHI

If Where Col = 'ABCDEFGH' the result should be: ABCDEFGH, ABCDEFGHI

If Where Col = 'ABCDEFGHI' the result should be: ABCDEFGHI

https://stackoverflow.com/questions/67377477/what-is-the-most-standard-criteria-for-partial-match-in-sql-select-queries May 04, 2021 at 08:50AM

没有评论:

发表评论