MySQL查询

查询需要用到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()

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容