zoukankan      html  css  js  c++  java
  • sql语句

    --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
    
     
    
    好记性不如烂博客
  • 相关阅读:
    python实战===短信验证码的小项目
    pillow模块的学习
    安全测试===8大前端安全问题(下)
    安全测试===8大前端安全问题(上)
    移动端测试===Android内存泄露和GC机制(转)
    识别验证码
    网址
    自动化测试===Macaca环境搭建,自我总结
    linux===Ubuntu修改设备名称
    macaca安装失败的解决办法!
  • 原文地址:https://www.cnblogs.com/huazaizai/p/1789566.html
Copyright © 2011-2022 走看看