以下是一些主要的SQL语句的语法实例
SELECT(查询某列)SELECT column_name(s)FROM table_nameSELECT DISTINCT(消除重复的元组)SELECT DISTINCT column_name(s)FROM table_nameSELECT * (查询表中的所有数据)SELECT *FROM table_nameWHERE(范围限定) SELECT column_name(s)FROM table_nameWHERE column_name operator valueLIKE (匹配查询,注意:有5种通配符)SELECT column_name(s)FROM table_nameWHERE column_name LIKE patternORDER BY (排序:ASC升序,DESC降序)SELECT column_name(s)FROM table_nameORDER BY column_name [ASC|DESC]INNER JOIN(内连接)SELECT column_name(s)FROM table_name1INNER JOIN table_name2 ON table_name1.column_name=table_name2.column_nameLEFT JOIN (左外连接)SELECT column_name(s)FROM table_name1LEFT JOIN table_name2 ON table_name1.column_name=table_name2.column_nameRIGHT JOIN(右外连接)SELECT column_name(s)FROM table_name1RIGHT JOIN table_name2 ON table_name1.column_name=table_name2.column_nameFULL JOIN (全外连接)SELECT column_name(s)FROM table_name1FULL JOIN table_name2 ON table_name1.column_name=table_name2.column_nameINSERT INTO (插入数据)INSERT INTO table_nameVALUES (value1, value2, value3,....)orINSERT INTO table_name(column1, column2, column3,...)VALUES (value1, value2, value3,....)UPDATE (修改数据)UPDATE table_nameSET column1=value, column2=value,...WHERE some_column=some_valueDELETE (删除数据)DELETE FROM table_nameWHERE some_column=some_valueorDELETE FROM table_name (Note: Deletes the entire table!!)DELETE * FROM table_name (Note: Deletes the entire table!!)