模糊查询操作

-- ===================  模糊查询  ======================
-- 查询姓赵的同学
SELECT studentno,studentname FROM student 
WHERE studentname LIKE '赵%'

-- 查询姓赵的同学,名字后面只有一个字的
SELECT studentno,studentname FROM student 
WHERE studentname LIKE '赵_'

-- 查询姓赵的同学,名字后面只有二个字的
SELECT studentno,studentname FROM student 
WHERE studentname LIKE '赵__'

-- 查询名字中间有x字的同学
SELECT studentno,studentname FROM student 
WHERE studentname LIKE '%赵%'

-- ================== in (具体的一个或多个值) ====================
-- 查询1000,1001的学员
SELECT studentno,studentname FROM student 
WHERE studentno in (1000,1001)

-- 查询北京的学员
SELECT studentno,studentname FROM student 
WHERE address in ('北京朝阳')

  

上一篇:数据库篇2(增删查改)


下一篇:去重及数据库的表达式