1.搜索在某个范围内容的数据;
select * from A where 条件 betwen ?and ?
2.搜索某列值所有数据的和;
select sum (列) from 表名
搜索返回数据有几条
select count() from A
3.按照ID 倒叙排列
select * from A order by ID ASC
ASC 是正序排 也可以修改成 Desc 是倒序排
4.搜索非空数据;
select * from table where 条件 is not null (非空)
select * from table where 条件 is null(空)
5.搜索不为0的数据
select * from table where 字段<> 0(SQL语句查询某个字段不为0 )数据库里面<>表示为不等于
6.关联查询
SELECT a.,b.* FROM table_a a INNER JOIN table_b b ON a.id=b.id;(内连接)
SELECT a.,b. FROM table_a a LEFT JOIN table_b b ON a.id=b.id;(左关联)
SELECT a.,b. FROM table_a a RIGHT JOIN table_b b ON a.id=b.id;(右关联)
SELECT a.,b. FROM table_a a LEFT JOIN table_b b ON a.id=b.id WHERE b.id IS NULL;(左连接-内连接)
SELECT a.,b. FROM table_a a RIGHT JOIN table_b b ON a.id=b.id WHERE a.id IS NULL(右连接-内连接)
select 字段名 from 表1 ,表2 where 表1.字段名=表2.字段名(从两个表中找到相同的数据)