wzh789 发表于 2016-11-21 06:06:37

PostgreSQL之判断字段值被包含语句

  position(substring in string)  return position of substring.
  表code:

 
  找出code表中code_id字段值被'1-1-2-3-'包含的记录?
  ①, 

select code_id, code_value from code where position(code_id in '1-1-2-3-') > 0 ;
  ②, 

select code_id, code_value from code where '1-1-2-3-' like '%' || code_id || '%' ;
  结果:

 
页: [1]
查看完整版本: PostgreSQL之判断字段值被包含语句