zoukankan      html  css  js  c++  java
  • mysql in和find_in_set

    一、查询包含“,”的列

    1.如果查询条件包含单引号

    用in 

    如:select * from t_test where names in ('李红');

    只能查询出names列中值为‘李红’的数据

    select * from t_test where names in ('李红,李华');

    只能查询出names列中值为‘李红,李华’的数据

    用find_in_set

    如:select * from t_test where FIND_IN_SET('李红',names );

    能查出names列中包含‘李红’的列 如:李红,李华;李丽,李红;小明,李红

    select * from t_test where FIND_IN_SET('李红,李华',names );

    不能查询任何数据

    2.如果查询条件不包含单引号

    用in 

    如:select * from t_test where names in (李红);

    只能查询出names列中第一个值为‘李红’的数据。 如:李红,李华;李红,小明;不能查出:小明,李红。

    select * from t_test where names in (李红,李华);

    只能查询出names列中第一个值为‘李红‘的数据。

    用find_in_set

    如:select * from t_test where FIND_IN_SET(李红,names );

    能查出names列中包含‘李红’的列 如:李红,李华;李丽,李红;小明,李红

  • 相关阅读:
    小 X 的密码破译
    时光机
    战争
    iOS TDD
    iOS url schemes应用


    二分查找
    搜索
    链表
  • 原文地址:https://www.cnblogs.com/susuhyc/p/8004405.html
Copyright © 2011-2022 走看看