www.fltk.net > mysql 怎么查询一个字段对应的多个值

mysql 怎么查询一个字段对应的多个值

select * from tablename where ziduan1 =1 or ziduan2 = 1 你可以到w3cschool里面看看这些语句什么的http://www.w3school.com.cn/sql/sql_and_or.asp

select * from otim where sheetid in(1,2,3)

select 姓名 from 表名 where 字段2 in ('三好学生','进步学生') group by 姓名 having count(distinct 字段2)=2字段2就是三好学生什么的那个字段,名称自己换一下

in(v1,v2..vn) ,符合v1,v2,,,vn才能被查出 IN关键字可以判断某个字段的值是否在指定的集合中。如果字段的值在集合中,则满足查询条件,该纪录将被查询出来。如果不在集合中,则不满足查询条件。其语法规则如下:[ NOT ] IN ( 元素1, 元素2, …, ...

SELECT m.aid,m.b1id,n.bcon,m.b2id as b2id,o.bcon as b2con, m.b3id as b3id,p.bcon as b3con FROM `test` as m INNER JOIN test1 as n on m.b1id=n.bid INNER JOIN test1 as o on m.b2id=o.bid INNER JOIN test1 as p on m.b3id=p.bid; 结果:

select * from 表名 where name like ‘%张%’and abcName like ‘%李%’ 用and连接

代码如下: SELECT * FROM news_extinfo where (ExtID = 1 and OptionValue = 0) or (ExtID = 2 and OptionValue = 0 ) or (ExtID = 3 and OptionValue = 0 ) group by NewsID having count(*)=3 此处 count(*) = 3 表示的意思是 在查询的结果中...

1、创建表 create table a (name varchar(20) not null,sex varchar(10)); create table b (name varchar(20) not null,sex varchar(10)); 2、插入值 insert into a values('john','male');insert into b values('john','male'); insert into a ...

1、一般查询语句:SELECT `lcontent` FROM `caiji_ym_liuyan` 查询数据: 2、有些时候需要查询某个字段的长度为多少时候才显示数据: SQL语句:SELECT `lcontent` FROM `caiji_ym_liuyan` where length(lcontent)

SELECT ename 员工姓名,sal 工资,deptno 部门 FROM emp WHERE sal IN(SELECT max(sal) FROM emp GROUP BY deptno) 其实就是先查出来每个部门中最高的工资,然后在用表格做查询时,在where中限制条件就行。

网站地图

All rights reserved Powered by www.fltk.net

copyright ©right 2010-2021。
www.fltk.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com