SQL命令

SQL查询窗口 选择哪行执行哪行,不选择则从上到下依次执行

delete from xsxx where xsxm is null    /****** 删除所有xsxm为null的记录******/

select * from xsxx where xsxm like '张%' //显示所有姓张的记录

select  distinct tx from tiku where tx is not null//显示表中TX不空的所有不重复的TX值

 

select * from tiku where tx is not null   //显示tiku中所有TX不是NULL的所有记录信息
select REPLACE(tx,'.jpg','') from tiku where tx is not null  //显示tiku中所有TX不是NULL的所有TX去掉“.jpg"后所有信息
update tiku set tx=REPLACE(tx,'.jpg','') from tiku where tx is not null //将所有TX不是NULL的所有记录的TX值替换为”去掉.JPG"后的内容

order by convert(xsxm using gbk) desc//根据汉字拼音顺序来显示记录

 create table test2 ('a' varchar(100),'b' varchar(10), key 'k_a' ('a') ,key 'k_b' ('b'), unique key 'u_k' ('a','b'))

select count(*) from (select distinct wz from xinxi) a 统计xinxi表中所有不重复的WZ的总数(一定要起个别名)

update hnyy set ysid=replace(ysid,'\n','')替换字段中的换行再更新

insert ignore into hnyy_copy2 select replace(ksid,'\n',''),replace(ysid,'\n',''),replace(xm,'\n','') from hnyy 用另一表中去除换行符后的内容插入到另一表中

下面命令一 次性显示三个结果,涉及三个表或三个不同内容:

select s.num1,t.num2 ,u.num3 from
(select count(*) num1 from sp) s,
(select count(*) num2 from spid) t,
(select count(*) num3 from spid where bz='1') u

posted @ 2020-11-07 09:25  myrj  阅读(123)  评论(0编辑  收藏  举报