用过的mysql命令

set charset GBK

SET NAMES utf8

130:
show processlist;
 kill 837

select * from post p, post_channel pc
where pc.ID=p.cID
and p.replyid is null
and to_days(now())-to_days(p.sendTime)<=1
and pc.typecode='jj'
order by p.visitedCount desc

select distinct pc.ID
from post_channel pc,post_channelinfo pcinfo, post p, postinfo pinfo
where p.cid=405 and pinfo.postid=p.id and
(pcinfo.UID=pinfo.uid or pcinfo.uid=p.sender) AND
pc.id=pcinfo.POST_CHANNEL_ID and pc.LOGOPATH is not null

 explain
select distinct p.*
from production p,production_remark pr
where p.status=1 and p.deleted=0 and pr.pid=4177
and p.id!=4177 and p.type=3
 and p.sender in (pr.remarkerid,781)

select * from production p where
p.sender=133 and p.status=1

select * from post p where p.replyid is null and p.sender=5816

select * from user u where u.id=1650

update Evaluation e set e.Rating1=round(7*rand()) where e.productionid<1000

call handlerdemo(8933)
DROP PROCEDURE IF EXISTS handlerdemo;
CREATE PROCEDURE handlerdemo (in pid INT)
begin
DECLARE done INT DEFAULT 0;
declare tmp DATETIME;
declare rtime DATETIME;
declare rid INT;
declare cur_tbl cursor for select sr.id,sr.regTime from survey_result sr where sr.productionid=pid;
select p.sendTime into tmp from production p where p.id=pid;
open cur_tbl;
repeat
fetch cur_tbl into rid,rtime;
IF NOT done THEN
set tmp=addtime(tmp,concat('0 0:0:',cast(round(7*rand()+10) as CHAR)));
update survey_result sr set sr.regTime=tmp where sr.id=rid;
end if;
until done end REPEAT;
close cur_tbl;
end;

select count(*) as col_0_0_ from post post0_, post_channel postchanne1_, postinfo postinfo2_ where post0_.ID=postinfo2_.POSTID and postchanne1_.statuses=2 and postchanne1_.ID=post0_.CID and (post0_.REPLYID is null) and to_days(now())-to_days(postinfo2_.VISITTIME)<=1 group by postinfo2_.POSTID
 
select p.* from post p, post_channel pc
where pc.statuses=2 and p.replyid is null and p.cid=pc.id
order by p.replyCount+p.visitedCount desc

select * from user u where u.username like '灰狼太岁'

select pinfo.brandid,count(*) from production p, production_info pinfo
where pinfo.productionid=p.id and p.type=6
--and pinfo.brandid=1
group by pinfo.brandid order by pinfo.brandid

select pc.id,count(*) from production p,production_info pinfo,production pc
where pinfo.productionid=p.id and  p.type=11 and p.aid=369
and pc.id=pinfo.brandid
group by pinfo.brandid

select ep.id,u.username,e.prizename,u.realname,u.address,u.postcode,
u.phone,u.mobile,ep.ext_date
from ext_prize ep, user u,encash e
where u.id=ep.userid and ep.prizeid=e.id and ep.status=0

select * from ext_prize ep,encash e,user u
where ep.prizeid=e.id and ep.userid=u.id and ep.status=0

select distinct admin_id from post_channel_admin pca
where pca.admin_id not in (select u.id from user u)

select vp.*,u.username from vote_production vp,user u
where vp.uid=u.id and vp.productionid=15751

 

250:
insert dict (keyword)
select concat('wl',substr(keyword,3,15)) as keyword from dict where keyword like 'cd_post_%'

 select * from post p, post_channel pc
 where p.cid =pc.id and
   pc.code like 'cX%'
 
  select * from post p
 where p.cid in
  ( select pc.id from post_channel pc
  where pc.code like '%cx%') order by id desc
 
select post.title,post.sendTime,post.senderName,pc.name
from post,post_channel pc
where post.cid=pc.id and post.sender=1629

select  count(*)
from production p
where p.sender=1667
and DATE(p.sendTime)>(ADDDATE(CURRENT_DATE(), INTERVAL -1 DAY))
and DATE(p.sendTime)<(ADDDATE(CURRENT_DATE(), INTERVAL 1 DAY))

select p.*  from production p,production_info pInfo, Evaluation e
where p.id=pInfo.productionid and p.id=e.productionid
and p.status=1 and p.deleted=0 and p.type=3  
order by (e.rating1+e.rating2+e.rating3+e.rating4+e.rating5+p.visitedcount+p.remarkedcount)  desc

select * from production p,production_info pinfo,brand b
where p.id=pinfo.productionid and pinfo.brandid=b.id and
p.type=3 and p.STATUS=1 and p.deleted=0
and (p.title like '%a%' or p.label like '%a%' or p.remark like '%a%' or b.name like '%a%')

select distinct p.id from post p,postinfo p1,postinfo p2
where p.id=p1.postid and p1.uid=p2.uid and p2.postid=1
and p.id<>1 and p.replyid is null

select * from post_channelinfo p
where TO_DAYS(NOW()) - TO_DAYS(p.jointime) <= 7
group by p.post_channel_id
order by count(*) desc

select distinct pci.post_channel_id from post_channelinfo  pci,postinfo pinfo
where pci.uid=pinfo.uid and pinfo.postid=119


select pc.* from post_channel pc where pc.id in (
select pcinfo.post_channel_id from post_channelinfo pcinfo
where  pcinfo.uid in (select p.sender from post p where p.cid=21)
or pcinfo.uid in
(select pinfo.uid from post p,postinfo pinfo where p.id=pinfo.postid and p.cid=21)
)


select distinct pc.* from post_channel pc,post_channelinfo pcinfo
where pc.id=pcinfo.post_channel_id
and (pcinfo.uid in (select p.sender from post p where p.cid=21)
or pcinfo.uid in (select pinfo.uid from post p,postinfo pinfo where p.id=pinfo.postid and p.cid=21))


select * from post_channel postchanne0_, post_channelinfo post_chann1_ where postchanne0_.ID=post_chann1_.POST_CHANNEL_ID and (post_chann1_.UID in (select post2_.SENDER from post post2_ where post2_.CID=21) or post_chann1_.UID in (select postinfo4_.UID from post post3_, postinfo postinfo4_ where post3_.ID=postinfo4_.POSTID and post3_.CID=21)) limit ?


select p from Post p where p.id in (
select distinct p1.postid from Postinfo p1,Postinfo p2
where p1.uid=p2.uid and p2.postid= ? and p.replyid is null) and p.id<> ?


select p.sender,p.cid from post p
group by p.sender,p.cid

select u.* from post_channel_admin pca,user u where pca.admin_id=u.id and channel_id=397

select p.sendTime from production p
where (p.sendTime)>CONVERT('2008-04-20 16:00:00',DATETIME,'yyyy-MM-dd hh:mm:ss')

select cast(a.createTime as CHAR) from activity a

select * from tmp_release_account p where p.release_time like '2008-05-17%'

select * from post p,post_channel pc where p.cid=pc.id and pc.typeCode='jj' limit 10


show processlist;

select * from post post0_, post_channel postchanne1_
where postchanne1_.typeCode='jj'
and postchanne1_.ID=post0_.CID
and (post0_.REPLYID is null)
and to_days(now())-to_days(post0_.SENDTIME)<=1
order by post0_.VISITEDCOUNT desc

 

select pinfo.brandid, SUM(sa.score>0),COUNT(*)
from production p,
production_info pinfo,
survey_result sr,
survey_answer sa,
survey_questions sq

where
p.id=pinfo.productionid and p.type=6 and p.id=sr.productionid
and sq.id=718
and sq.id=sa.questionid
and sr.answerid=sa.id
--and sa.score>0
group by pinfo.brandid


select distinct production0_.id
 from production production0_, production_remark production1_
where production0_.type=3 and production0_.STATUS=1
and production0_.deleted=0 and (production0_.SENDER=production1_.REMARKERID
and production1_.PID=7640 or production0_.SENDER=1667) and production0_.ID<>7640

select distinct production0_.ID,production0_.type
 from production production0_, production_remark production1_
 where --production0_.type=3 and
 production0_.STATUS=1
 and production0_.deleted=0
 and (production0_.SENDER=production1_.REMARKERID and production1_.PID=4177
 or production0_.SENDER=781)
 and production0_.ID<>4177

 

 

call handlerdemo ();
DROP PROCEDURE IF EXISTS handlerdemo;
CREATE PROCEDURE handlerdemo ()
begin
DECLARE done INT DEFAULT 0;
DECLARE num INT DEFAULT 1;
declare tmp DATETIME;
declare rtime DATETIME;
declare rid INT;
declare cur_tbl cursor for select sr.id,sr.regTime from survey_result sr where sr.productionid=8901;

select p.sendTime into tmp from production p where p.id=8901;

open cur_tbl;
repeat
fetch cur_tbl into rid,rtime;
IF NOT done THEN

set tmp=addtime(tmp,'0 0:0:30');
update survey_result sr set sr.regTime=tmp where sr.id=rid;

set num=num+1;
end if;
until done end REPEAT;
close cur_tbl;
select num;
end;

select p.sendTime from production p where p.id=8901;
--select rid,addtime(rtime,'0 0:0:30');

update post_channel pc set pc.ishot=1


select * from production p, production_info pinfo, brand b,
post_channel pc, post_channel_ext pce
where pc.id=pce.post_channel_id and b.name=pc.name and p.id=pinfo.productionid
and p.type=9 and p.status=1 and p.deleted=0 and p.sender=pce.shopManId

select * from production p where p.type=9


select address
from user user0_ where user0_.username ='test'

select *
from production production0_, production_info production1_
where production1_.productionid=production0_.ID
and production1_.brandid=12678 and production0_.STATUS=1
and production0_.deleted=0
order by production0_.ID

select count(apc.category_name) as aaa,apc.category_name
from ask_problem_category apc where lenapc.parent_id
group by apc.category_name order by aaa desc

select * from  ask_problem_category apc where apc.parent_id=165

 

stop slave;

set GLOBAL SQL_SLAVE_SKIP_COUNTER=1;

start slave;


select UNIX_TIMESTAMP('2010-8-16 15:37')

select FROM_UNIXTIME( 1156219870 ,'%y-%M-%d %H:%m:%s' )

SELECT AUTO_INCREMENT FROM information_schema.tables WHERE table_name = 'cdb_uc_members';

alter table `cdb_uc_members` AUTO_INCREMENT=193

SET FOREIGN_KEY_CHECKS=0;

你可能感兴趣的:(sql,mysql,unix,ext,mobile)