Whether the fields in the database contain comma-separated fields contain certain characters

1. Use the function instr
instr(',' || PRINCIPAL || ',', ',' || #{principal} || ',')>0

The fields in the database are

After using this method, it is equivalent to splicing a comma before and after the image


instr(',' || '24,43' || ',', ',' || '43' || ',')>0

2. Use the function FIND_IN_SET(str, strlist) (field values ​​can only be separated by commas )

SELECT FIND_IN_SET("c", "a,b,c,d,e"); 

Using this method, the sql statement can become as follows:

select name,project from ic_customer where FIND_IN_SET('24',PRINCIPAL)

The above where statement is equivalent to FIND_IN_SET('1', brand_management) > 0 , except that the default query is the result of index > 0.

Guess you like

Origin blog.csdn.net/weixin_55823910/article/details/125215129