mysql中字段包含有关问题

mysql中字段包含问题

mysql数据表中包含两个字段,字段类型 为字符串,其中一个字段可能包含另一个字段的内容,如下所示

a b

130000 130000,130001

120001 110000

在上述表格中第一行,字段b包含字段a的内容130000;而第二行,字段b不包含字a的内容。

现在需要把 像第一行这样的数据搜索出来,请问有何好的方法呢?



select * from mysql数据表 where find_in_set(a,b)



SQL code

root@localhost : test 01:14:58>select * from cs;
+-------+----------+
| a     | b        |
+-------+----------+
| 123   | 123,234  |
| 11    | 12,13,32 |
| 54,43 | 54       |
+-------+----------+
3 rows in set (0.00 sec)

root@localhost : test 01:15:52>select * from cs where find_in_set(a,b);
+------+---------+
| a    | b       |
+------+---------+
| 123  | 123,234 |
+------+---------+
1 row in set (0.00 sec)


                        
  
  
                    
mysql中字段包含有关问题

相关文章:

你感兴趣的文章:

标签云: