/*联合查找*/
SELECT `user`.`name` AS 读者, book.bookName AS 书名 FROM `user`,book WHERE `user`.id = book.hid;
/*内联查找*/
SELECT `user`.`name`AS 读者,book.bookName AS 书名 FROM `user` INNER JOIN book WHERE `user`.id = book.hid;
/*查询语句*/
SELECT * FROM book AS b WHERE b.bookId = '1' && b.hid = '1' ;
/*更新语句*/
UPDATE grade SET grade = 4.6,time = NOW() WHERE id = '2' AND bookId = '1';
-- 删除表
drop table if exists tb_user;
-- 创建表
create table tb_user
(
-- id 主键,自动递增
id int primary key auto_increment,
-- 用户名
username varchar(20),
-- 密码
password varchar(32)
);
-- 插入数据
insert into tb_user (username,password)
values ('zhangsan','123'),
('lisi','234');
-- 查询表
select * from tb_user;
我的sql语句笔记
于 2022-02-13 19:01:08 首次发布