--insert insert into dbo.food ([name], remark) values ('火爆大头菜','好吃不得了') --select select count(*) from menu select * from food select * from food where [remark] like '%不得了%' --update update food set remark=replace(remark,'肉类产品','好吃锅包肉') update food set remark+='油炸' where id=1 --delete delete food where id=5 --关联 select * from food inner join price on food.id=price.foodid inner join menu on price.menuid=menu.id where menu.id=1 select [food].[id], [food].[name], [remark],[price],[menu].[name]from food inner join price on food.id=price.foodid inner join menu on price.menuid=menu.id where menu.id=1 select [food].[id], [food].[name], [remark],[price],[menu].[name]from food inner join price on food.id=price.foodid inner join menu on price.menuid=menu.id order by [food].[id] --升序 desc --降序 --分页 select top 3 row_number() over (order by [food].[id]) as row_no , * from food select * from (select top 6 row_number() over (order by [food].[id] desc) as row_no , [food].[id] as foodid, [food].[name] as foodname, [food].[remark] as foodremark,[price].[price] ,[menu].[name] as menuname from food inner join price on food.id=price.foodid inner join menu on price.menuid=menu.id )as newtable where row_no>2 and row_no<4 select top 6 row_number() over (order by [foodid] desc) as row_no,* from (select [food].[id] as foodid, [food].[name] as foodname, [food].[remark] as foodremark,[price].[price] ,[menu].[name] as menuname from food inner join price on food.id=price.foodid inner join menu on price.menuid=menu.id where menu.id=1) --显示春季价格 as hgj --加上row_no select top 3 row_number() over (order by [id]) as row_no ,* from food order by id desc