//查询所有数据select * from users;
//特定的列select username,email from users;
//where条件查询select * from users where is_active = true;
//升序select * from users order by birthdate;
//降序select * from users order by birthdate desc;
//limit限制返回的行数select * from users limit 10;
where子句
//运算符and和通配符select * from users where username like 'j%'and is_active = true;
//orselect * from users where is_active =trueor birthdata < ‘2005-1-1’;
//INselect * from users where birthdate in ('2005-1-1','2000-9-9','2000-8-8');
更新数据
update table_name set column1 = value1, column2 = value2,... wherecondition;
eg:
UPDATE orders
SET status ='Shipped', ship_date ='2023-03-01'WHERE order_id =1001;
删除数据
DELETEFROM table_name WHEREcondition;
like 模糊匹配
select column1, column2, ... from table_name where column_name LIKEpattern;
union 连接两个以上的select语句的结果,将其组合到一个结果集合,出去重复的行
SELECT column1, column2, ...
FROM table1
WHERE condition1
UNIONSELECT column1, column2, ...
FROM table2
WHERE condition2
[ORDERBY column1, column2, ...];