[Database] MySQL's SQL queries

Introduce a relational table

  • Class Schedule


  • Student Table


  • Course Table


Two SQL query format introduced

/* SQL查询的一般格式
    SELECT [ALL | DISTINCT] [* | coulmnNameA,coulmnNameB,...] 
        FROM [tableName | viewName | (select语句)] 
        [AS 结果表的别名]
        [WHERE 条件表达式x]
        [GROUP BY coulmnName1 [HAVING 条件表达式y]]
        [ORDER BY coulmnName2 [ASC | DESC]]
        [LIMIT startRow,targetRows]
    【各子句的处理顺序】FROM - WHERE - GROUP BY - HAVING - SELECT - ORDER BY
    【关键词释义】
        + GROUP BY coulmnName : 将结果按 coulmnName 的值分组·,该属性列中值相等的分为一组
        + HAVING 条件表达式 : 若 GROUP BY 子句带HAVING短语,则: 只有满足指定条件的组才予以输出
*/

Three inquiries Case

references

Guess you like

Origin www.cnblogs.com/johnnyzen/p/12535602.html