查询语句select
mysql使用select查询mysql数据库,selcet *表示从表里查询所有数据,如果需要查询某一行就需要where语句。
查询所有列select * from table。
查询固定列 select id from table
插入语句insert into
在mysql的世界里插入数据命令插入表数据用insert into。
插入数据insert into from table (userName, password)values('孤舟蓑笠翁','1234')
修改mysql数据
update table set password='1234', username='孤舟蓑笠翁' WHERE id=9
删除数据语句
delete from table where id=10
计算数据条数
select count(*) form table
as别称
select username as nickName form table
其他
后端常用的除了这些还会限制条数。and,or判断条件
限制条数:SELECT * FROM table LIMIT 3;
从多少条开始获取数据SELECT * FROM table LIMIT 0,2;
and:select * from table id=3 and id=4查询id为3和4的数据,
or:select * from table id=3 or id=4查询id为3和4的数据,
除了and和or,还有用运算符来表示条件,再次不多赘述了,如>,<,=,!=
如果需要模糊查询条件,需要使用like来完成
SELECT name FROM table WHERE name LIKE '%e%';
注意:删除和修改数据时需要加where判断条件
以上语句属于纯手写,如果有错误的话请指出