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 || '%' ;

结果:


 

猜你喜欢

转载自ssycssj.iteye.com/blog/2200751