SQL instr()函数的格式

格式一:instr( string1, string2 )    /   instr(源字符串, 目标字符串)
格式二:instr( string1, string2 [, start_position [, nth_appearance ] ] )   /   instr(源字符串, 目标字符串, 起始位置, 匹配序号)
解析:string2 的值要在string1中查找,是从start_position给出的数值(即:位置)开始在string1检索,检索第nth_appearance(几)次出现string2。
SELECT
  grade_type,
  teacher_name,
  grade_type->'$[*].id'
FROM tb_teacher
WHERE
(INSTR(grade_type->'$[*].id', '"1"') OR
      INSTR(grade_type->'$[*].id', '"2"') OR
      INSTR(grade_type->'$[*].id', '"3"') OR
      INSTR(grade_type->'$[*].id', '"4"') OR
      INSTR(grade_type->'$[*].id', '"5"') OR
      INSTR(grade_type->'$[*].id', '"6"'))
AND (!INSTR(grade_type->'$[*].id', '"7"')
      AND !INSTR(grade_type->'$[*].id', '"8"')
      AND !INSTR(grade_type->'$[*].id', '"9"')
      AND !INSTR(grade_type->'$[*].id', '"10"')
      AND !INSTR(grade_type->'$[*].id', '"11"')
      AND !INSTR(grade_type->'$[*].id', '"12"')
      AND !INSTR(grade_type->'$[*].id', '"13"')
      )
原文地址:https://www.cnblogs.com/87060524test/p/10402780.html