`

今天写的sql语句,可能以后用到几个

阅读更多
select*fromsort
selecttop10*fromv_companyuserswherecompanynamelike'%杭州天下%'
createindexadddateindexonv_companyusers(C_iddesc)
createviewV_CompanyUsers


select*fromssortwheress_id=627
select*fromcompanyinfowherec_id='69958F6E'
as
selecta.[C_ID],[CompanyName],[GenderID],[Introduce],[LogoPath],[CompanyPath],[PurchaseProduct],[MainProduct],[DealType],[CompanyType],[Sort],[SortOrder],[regMoney],[regTime],[regPlace],[CompanyAdderss],[FoundTime],[PPerson],[PSex],[PDept],[PDuty],[PAddress],[PZip],[PTel],[PEmail],[PPhone],[PMobile],[PFax],[PQQ],[PMSN],[PWebSite],[KeyWord],[KeyStartTime],[KeyEndTime],[AddTime],[Scores],[Award],[IsPass],[PassTime],[PassAdmin],[OpenedMonth],[IsPayment],[IsPersonUpdate],[PersonUpdateTime],[IsCompanyUpdate],[CompanyUpdateTime],[IsContentUpdate],[ContentUpdateTime],[oldID1],[isdelete],[U_Account],[U_NickName],[U_Sex],[U_Password],[U_Question],[U_Answer],[U_Note],[U_Chk],[U_AddTime],[U_LoginNum],[U_LastTime],[FirstApplyDate],[IsFirstPass],[Reason],[FirstPassDate],[IsAdvancedApply]fromcompanyinfoa,userinfobwherea.c_id=b.c_id

select*from[zj123_b2b].[dbo].sortwhereColumn_name='矿业设备'

select*fromb_company
selectc_id,c_name,ss_id,ss_name,t.Column_id,t.column_Namefromb_companya,ssortb,(select*fromOPENROWSET('SQLOLEDB','127.0.0.1';'sa';'',[zj123_b2b].[dbo].Sort))twherea.ssort=b.ss_idandt.column_name=b.ss_name

selectdistinctc_id,c_name,ss_id,ss_name,t.column_Namefromb_companya,ssortb,(select*fromOPENROWSET('SQLOLEDB','127.0.0.1';'sa';'',[zj123_b2b].[dbo].Sort))twherea.ssort=b.ss_idandt.column_name=b.ss_name


selectmin(Column_id)fromselectmin(Column_ID)from[zj123_b2b].[dbo].sortwheregroupbyColumn_Name
--deletefrom[zj123_b2b].[dbo].sortwhereColumn_IDnotin(selectdistinctParent_IDfrom[zj123_b2b].[dbo].sort)andColumn_IDnotin(selectmin(Column_ID)from(selectdistinct*from[zj123_b2b].[dbo].sortwhereColumn_IDnotin(selectdistinctParent_IDfrom[zj123_b2b].[dbo].sort))tgroupbyColumn_Name)

deletefrom(selectColumn_IDfrom(selectdistinct*from[zj123_b2b].[dbo].sortwhereColumn_IDnotin(selectdistinctParent_IDfrom[zj123_b2b].[dbo].sort))tgroupbyColumn_Name)twheret.Column_idnotin(selectmin(Column_ID)from(selectdistinct*from[zj123_b2b].[dbo].sortwhereColumn_IDnotin(selectdistinctParent_IDfrom[zj123_b2b].[dbo].sort))tgroupbyColumn_Name)
其他未分类

deletefrom[pubs].[dbo].city


--deletefrom[zj123_b2b].[dbo].sortwherecolumn_idin(selectcolumn_idfrom[zj123_b2b].[dbo].sortwhereColumn_idin(selectParent_idfrom(select*from[zj123_b2b].[dbo].sortwhereparent_id!='')t)andcolumn_depth=1)

select*from[zj123_b2b].[dbo].sortwherecolumn_name='作业保护'

selectcolumn_name,count(*)from[zj123_b2b].[dbo].sortwherecolumn_idin(selectdistinctparent_idfrom[zj123_b2b].[dbo].sort)groupbycolumn_name

deletefrom[zj123_b2b].[dbo].sortwherecolumn_id='66B072'

update[zj123_b2b].[dbo].sortsetparent_id='5DD717'wherecolumn_idin(selectcolumn_idfrom[zj123_b2b].[dbo].sortwhereparent_id='00D5CC')

update[zj123_b2b].[dbo].sortsetparent_id='5D4160'wherecolumn_idin('56C0C7')

select*from[zj123_b2b].[dbo].sortwhereparent_id='FE80CC'

select*from[zj123_b2b].[dbo].sortwherecolumn_id='5E0EA9'

select*from[zj123_b2b].[dbo].sortwherecolumn_namein(selectcolumn_namefrom[zj123_b2b].[dbo].sortgroupbycolumn_namehavingcount(*)>1)orderbycolumn_namedesc


----------------------------------------------------------------------------------------------------

selectmin(Column_id),count(*),column_namefrom[zj123_b2b].[dbo].sortwherecolumn_depth=3groupbycolumn_namehavingcount(*)>1

--deletefrom[zj123_b2b].[dbo].sortwhereColumn_idin(selectmin(Column_id)from[zj123_b2b].[dbo].sortwherecolumn_depth=1groupbycolumn_name)

select*from[zj123_b2b].[dbo].sortwherecolumn_depth=1orderbycolumn_name

--------------------------------
--
--第二步
select*from[zj123_b2b].[dbo].sortwherecolumn_depth=2orderbycolumn_name

selectmin(Column_id),count(*),column_namefrom[zj123_b2b].[dbo].sortwherecolumn_depth=2groupbycolumn_namehavingcount(*)>1

select*from[zj123_b2b].[dbo].sortwherecolumn_id='0BAF08'

--------------------------------
select*from[zj123_b2b].[dbo].sortwherecolumn_depth=1orderbycolumn_namedesc,column_id

selectmax(Column_id),column_name,count(*)from[zj123_b2b].[dbo].sortwherecolumn_depth=1groupbycolumn_namehavingcount(*)>=1

select*from[zj123_b2b].[dbo].sortwherecolumn_depth=3orderbycolumn_namewherecolumn_id='0BAF08'


---------------------------------------------------------------------------------/////////////////
update[zj123_b2b].[dbo].sortsetparent_id='0796CE'whereparent_id='19E861'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='9671CF'whereparent_id='D4FD84'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='5A6E06'whereparent_id='6073F5'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='AC3D13'whereparent_id='DC5E01'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='74F0CB'whereparent_id='A61268'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='6103A9'whereparent_id='6C5C7E'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='4CC1DF'whereparent_id='F68730'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='6A726A'whereparent_id='9CC1B5'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='C2DFDB'whereparent_id='D578E2'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='2A5475'whereparent_id='C89C65'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='037721'whereparent_id='E06107'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='8A62FE'whereparent_id='F256E9'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='70B5BD'whereparent_id='F24EC3'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='82F523'whereparent_id='C591DE'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='72F93F'whereparent_id='8A0552'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='5E0EA9'whereparent_id='19E861'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id='0796CE'whereparent_id='CEBE72'andcolumn_depth=2
update[zj123_b2b].[dbo].sortsetparent_id=<
分享到:
评论

相关推荐

    经典全面的SQL语句大全

    10、说明:几个简单的基本的sql语句  选择:select * from table1 where 范围  插入:insert into table1(field1,field2) values(value1,value2)  删除:delete from table1 where 范围  更新:update table1 ...

    SQL.rar_SQL语句

    几个经典的sql语句示例,方便实用。不多,但是会经常用到

    SQL实用语句,工作中用到的

    几个常见的SQL语句,是我个人用到比较多的。后续会持续往里面增加。 有截图有文字有解释,希望大家喜欢。

    易语言批量sql解析为数组, SQL终结符解析

    前段时间在写一个服务端程序的时候, 需要用到mysql.客户端连接服务端执行sql分好几种情况, { 查询SQL, 执行SQL, 执行SQL事务, 批量执行支持, 查询执行混合 } ...其中的"批量执行"就有点让我头疼, 玩过sql的都知道, ...

    SQL语句 根据月份产生出勤人员月份日历报表

    一个SQL存储过程: 出勤资料查询 根据月份产生出勤人员月份日历报表 用到2个表:M_Users(用户表)、X_ITAttendance(用户出勤资料表),查询出的格式如桌面日历,日期不存在的以NULL值显示,存在的显示总的出勤时间...

    MYSQL常用命令大全

    然后使用source命令,后面参数为脚本文件(如这里用到的.sql) mysql&gt;source wcnc_db.sql B:使用mysqldump命令 mysqldump -u username -p dbname &lt; filename.sql C:使用mysql命令 mysql -u username -p -D dbname ...

    SQL查询安全性及性能优化

    首先可以帮助我们查看SQL语句是否利用到索引,比如很复杂的SQL语句中有些用到索引,但是执行计划中却没有索引查找,我们就可以分析相应的原因 然后我们可以对比不同的执行计划,比如达到同样效果,两个开发人员...

    Oracle、MySQL和SqlServe三种数据库分页查询语句的区别介绍

    先来定义分页语句将要用到的几个参数: int currentPage ; //当前页 int pageRecord ; //每页显示记录数 以之前的ADDRESSBOOK数据表为例(每页显示10条记录): 一、SqlServe下载 分页语句 String sql = select ...

    易语言-易语言批量sql解析为数组, SQL终结符解析

    于是前段时间论坛有几个帖子被顶起来了, 一个叫"无间酱"的大佬制作了好几个练手的脚本语言设计, 我灵机一动... 脚本也会遇到这样的问题, 就把源码中的解析终结符部分给抠出来了... 总算说到重点了. 刚开始还不能...

    java音像店管理系统

    主要有四个模块,十几个类。 Java数据库编程主要使用JDBC技术。JDBC是一种用于执行SQL语句的Java API。它由一组用Java编写的类和接口组成。JDBC为开发者提供了一个标准的API,使他们能够用纯JavaAPI来编写数据库应用...

    SQL中SET和SELECT赋值的区别

    最近的项目写的SQL比较多,经常会用到对变量赋值,而我... 说到这个,SQL内置的变量:@@ERROR 和 @@ROWCOUNT必须要在一句SQL语句中捕获。如果用set分两句来获取它们,将获取不完整,这时就应该用select来获取值。 */

    WordPress必备数据库SQL查询语句整理

    这个期间也用到了SQL查询语句来批量的对内链的HTTP前缀做替换,就感觉掌握一些SQL方面的语句还是非常有必要的,这不在【俄语译客】博客上就发现了几条比较实用的,适合 WordPress 实用的SQL语句。于是就赶紧收集分享...

    Oracle SQL高级编程(资深Oracle专家力作,OakTable团队推荐)--随书源代码

    6.2.4 标识SQL语句以便以后取回计划 153 6.2.5 深入理解DBMS_XPLAN的细节 156 6.2.6 使用计划信息来解决问题 161 6.3 小结 169 第7章 高级分组 170 7.1 基本的GROUP BY用法 171 7.2 HAVING子句 174 7.3 GROUP...

    精通SQL 结构化查询语言详解

    1.5.3 SQL语句的结构  1.5.4 SQL的优点  1.5.5 SQL的执行  1.6 SQL环境  1.6.1 环境  1.6.2 SQL的层次结构  1.6.3 客户程序和服务程序系统  1.6.4 SQL环境中对象的命名规则  第2章 主要的关系...

    SQL语法大全

    以上几个游标类型将直接影响到Recordset对象所有的属性和方法,以下列表说明他们之间的区别。 ------------------------------------------------------------- Recordset属性 adOpenForwardOnly adOpenKeyset ...

    非常好用的sql语句(日常整理)

    本文给大家分享几个比较好用的sql语句,在数据库中经常会用到,需要的朋友可以参考下本篇文章。

    全面接触SQL语法

    SQL语法的分类 &lt;br&gt; 其实SQL命令并不是非常多,可是要把SQL用到出神入化,却也只需要短短几个命令便够,因为SQL命令是针对关系型数据库所建立出来的语法叙述,所以SQL在这类数据库中所发挥的功能非常的强,以下...

    SQL性能优化

     以上四个SQL在ORACLE分析整理之后产生的结果及执行的时间是一样的,但是从ORACLE共享内存SGA的原理,可以得出ORACLE对每个SQL 都会对其进行一次分析,并且占用共享内存,如果将SQL的字符串及格式写得完全相同则...

Global site tag (gtag.js) - Google Analytics