基本插入語句:insert into table_namevalues (value1,value2,value3,...); (table_name:表名稱)延伸插入語句:
從一個表複製資料,然後把資料插入到一個已存在的表中:
insert into table2select * from table1;只複製希望的列插入到另一個已存在的表中:insert into table2 (column_name(s)) select column_name(s) from table1; (column_names:列名)
2.查詢語句:
基本查詢語句:
select * from table_name ----查詢整個表select column_name,column_name from table_name; ----查詢表中的某一列條件查詢語句 :select * from table_name where some_column=some_value or some_column=some_value;包含條件查詢語句select * from table_name where some_column like "% some_value%";"%"-- 萬用字元:
xx% -- 以xx開頭%xx -- 以xx結尾%xx% -- 有xx
delete from table_name where some_column=some_value;
SQL常用語句
插入語句:
基本插入語句:insert into table_namevalues (value1,value2,value3,...); (table_name:表名稱)延伸插入語句:從一個表複製資料,然後把資料插入到一個已存在的表中:
insert into table2select * from table1;只複製希望的列插入到另一個已存在的表中:insert into table2 (column_name(s)) select column_name(s) from table1; (column_names:列名)2.查詢語句:
基本查詢語句:
select * from table_name ----查詢整個表select column_name,column_name from table_name; ----查詢表中的某一列條件查詢語句 :select * from table_name where some_column=some_value or some_column=some_value;包含條件查詢語句select * from table_name where some_column like "% some_value%";"%"-- 萬用字元:xx% -- 以xx開頭%xx -- 以xx結尾%xx% -- 有xx
delete from table_name where some_column=some_value;4. 更新語句:
update table_nameset column1=value1,column2=value2,...where some_column=some_value;