查询需要用到select
查询表中所有数据
select * from tableid;
查询表中某项数据
select `id`,`id2`,...from tableid;
查询某项数据并去除相同项;
select distinct id from tableid;
查询自增步长
SELECT @@auto_increment_increment
查询时对数据操作
select `id`,`id2`+1 as 'new' from tableid;
查询某个区段的数据使用where
select `id` from tableid;
where condition;
两表链接,查询公共部分,给出一例
SELECT s.StudentNo,StudentName,SubjectNo,StudentResult
FROM student s
INNER JOIN result r
ON s.StudentNo=r.StudentNo
or and表示或 且
select `id` from tableid;
where condition1 and/or condition2;
升序用asc(Ascending order),降序用desc(descending)
select `id` from tableid order by condition desc/asc;
几个常用查询
最大 max()
最小min()
平均avg()
总数count()