这里分两种情况来介绍

1、in 后面是记录集,如:

select  *  from  table  where   uname  in(select  uname  from  user);

2、in 后面是字符串,如:

select  *  from  table  where   uname  in('aaa',bbb','ccc','ddd','eee',ffff'');

注意:这里一定要将字符串用单引号'' 标注起来;

3、in 后面是数组,用如下方法,请参考:

//$pieces是含数据的数组

for($i=0;$i<count($pieces);$i++){

$uname=$uname."'".$pieces[$i]."',";

}

$the_uname ="uname in(".$uname."'')";

select  *  from  table  where    ".$the_uname." ;

备注:这种方法的原理其实很简单,二就是把数组编程上面“第2种情况”的形式

mysql中 where in 用法详解的更多相关文章

  1. Mysql中limit的用法详解

    Mysql中limit的用法详解 在我们使用查询语句的时候,经常要返回前几条或者中间某几行数据,为我们提供了limit这样一个功能. SELECT * FROM table LIMIT [offset ...

  2. mysql中event的用法详解

    一.基本概念mysql5.1版本开始引进event概念.event既“时间触发器”,与triggers的事件触发不同,event类似与linux crontab计划任务,用于时间触发.通过单独或调用存 ...

  3. mysql中in的用法详解

    一.基础用法 mysql中in常用于where表达式中,其作用是查询某个范围内的数据. select * from where field in (value1,value2,value3,-) 当 ...

  4. mysql中limit的用法详解[数据分页常用]

    在我们使用查询语句的时候,经常要返回前几条或者中间某几行的数据,这个时候怎么办呢?不用担心,mysql已经为我们提供了这样一个功能. SELECT * FROM table LIMIT [offset ...

  5. C#中string.format用法详解

    C#中string.format用法详解 本文实例总结了C#中string.format用法.分享给大家供大家参考.具体分析如下: String.Format 方法的几种定义: String.Form ...

  6. c++中vector的用法详解

    c++中vector的用法详解 vector(向量): C++中的一种数据结构,确切的说是一个类.它相当于一个动态的数组,当程序员无法知道自己需要的数组的规模多大时,用其来解决问题可以达到最大节约空间 ...

  7. php中setcookie函数用法详解(转)

    php中setcookie函数用法详解:        php手册中对setcookie函数讲解的不是很清楚,下面是我做的一些整理,欢迎提出意见.        语法:        bool set ...

  8. mysql中SQL执行过程详解与用于预处理语句的SQL语法

    mysql中SQL执行过程详解 客户端发送一条查询给服务器: 服务器先检查查询缓存,如果命中了缓存,则立刻返回存储在缓存中的结果.否则进入下一阶段. 服务器段进行SQL解析.预处理,在优化器生成对应的 ...

  9. JavaScript中return的用法详解

    JavaScript中return的用法详解 最近,跟身边学前端的朋友了解,有很多人对函数中的this的用法和指向问题比较模糊,这里写一篇博客跟大家一起探讨一下this的用法和指向性问题. 1定义 t ...

随机推荐

  1. eclipse搭建ssm框架

    新建数据库ssm 建立数据库表user CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT , `sex` varchar(255) ...

  2. L273 NCAA

    On Friday, the system that prevents college athletes from being compensated for their labor (beyond ...

  3. L266 作文

     With the rapid development of modem society, an increasing number of people are concerned about the ...

  4. ueditor 设置高度height. ue.setHeight(400); 设置宽度 width

    1.引入的文件: <script type="text/javascript" src="../../dist/ueditor1_4_3-utf8-php/uedi ...

  5. C#窗体换肤

    Form1.cs using System;using System.Collections.Generic;using System.ComponentModel;using System.Data ...

  6. 7-log4j2之自定义Appender

    一.添加Maven依赖 <dependencies> <dependency> <groupId>org.apache.logging.log4j</grou ...

  7. 解决You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order (order_name, customer)

    在学习hibernate一对多映射关系时,根据视频学习的时候,例子是顾客和订单的问题,一个顾客有多个订单.按照视频中的敲代码出现了You have an error in your SQL synta ...

  8. Unknown parameter datatype UNKNOW send from server.

    procedure Tmainform.Button7Click(Sender: TObject); begin kbmMWClientQuery3.Query.Text:='insert into ...

  9. ISO-8859-1和GBK互转

    String slogn = "极简主义"; byte[] bytes = slogn.getBytes("GBK");// 编码:字符串变成字节数组 输入 参 ...

  10. html 网页代码大全,总结,使用

    )贴图:<img src="图片地址"> )加入连接:<a href="所要连接的相关地址">写上你想写的字</a> )贴图 ...