MySQL中特定格式的字符串部分完全匹配查询
2017-11-28 14:17
465 查看
转载:MySQL字符串操作
- 使用场景:
一个工单号对应多个保单号,其数据库存储形式,如下:
需求:
根据保单号查询工单,例如,保单号为8601时,显示3条数据;保单号为8602,显示1和2;保单为8604时,只显示4
SQL:
使用find_in_set(str,str1)函数
- 使用场景:
一个工单号对应多个保单号,其数据库存储形式,如下:
编号 | 工单号 | 保单号 |
---|---|---|
1 | YY1860120171127005 | 8601,8602,8603 |
2 | YY1860120171127006 | 8601,8602 |
3 | YY1860120171127007 | 8601,8603 |
4 | YY1860120171127008 | 8604 |
根据保单号查询工单,例如,保单号为8601时,显示3条数据;保单号为8602,显示1和2;保单为8604时,只显示4
SQL:
使用find_in_set(str,str1)函数
select * from t_order where find_in_set('8601',cont_no); select * from t_order where find_in_set('8602,cont_no); select * from t_order where find_in_set('8604,cont_no);
相关文章推荐
- mysql将查询部分数据导出到外部文件的脚本,文件格式替换
- MySQL中GROUP_CONCAT函数的使用,separator,将多行查询结果用特定字符串连接起来,适用于一对多
- MySQL中GROUP_CONCAT函数的使用,separator,将多行查询结果用特定字符串连接起来,适用于一对多
- MySQL匹配指定字符串的查询
- mysql 连接查询指的是将两张表或多张表关联到一起进行查询,获取一个表的行与另一个表的行匹配的数据。常见的连接查询包括内连接(等值连接)、左(外)连接、右(外)连接和交叉连接(完全连接)等
- MySQL匹配指定字符串的查询
- sql语句查询某字段中包含指定字符串的数据列表,完全匹配字段中逗号中间的字符串数据
- mysql字符串之大小写匹配查询
- mysql REGEXP 正则的实现两个字符串组的匹配(实现数据库字符串匹配查询)
- asp下实现截取字符串特定部分内容函数
- MySQL种字符串拆分(substring_index)并作为关联查询条件后多列展示
- 查询表里的字段,然后以字符串的格式输出,再用分隔符分开,成对出现
- 【转】MS Sql server 日期转换为特定字符串格式
- sql中生成查询的模糊匹配字符串
- mysql 指定日期格式查询
- MYSQL查询某字段中以逗号分隔的字符串的方法
- MYSQL中利用select查询某字段中包含以逗号分隔的字符串的记录方法
- MYSQL中利用select查询某字段中包含以逗号分隔的字符串的记录方法
- MYSQL中利用select查询某字段中包含以逗号分隔的字符串的记录方法find_in_set
- MySQL中日期与字符串相互转换,并进行日期比较查询