sql 查询语句

1.从另一张表中选择数据插入新表中

INSERT INTO orders (ISBN) SELECT DISTINCT ISBN FROM new_ratings;

2.报错You can't specify target table 'new_ratings' for update in FROM clause

UPDATE new_ratings SET bookid = (SELECT (orders.id) FROM orders,new_ratings WHERE orders.ISBN = new_ratings.ISBN)

修改后为:

update new_ratings join orders on new_ratings.ISBN=orders.ISBN set new_ratings.bookid=orders.id 

3.修改字段类型

alter table student alter column sno varchar(10) 

你可能感兴趣的:(sql 查询语句)