当前位置:首页 » 其他

SQL高级语句

2014-08-18 18:00 本站整理 浏览(7)

######mysql修改自增字段的起始值

alter table device AUTO_INCREMENT=214789

####

SELECT pin,

case id

when 10022 THEN '我的'

else '别人的'

end AS Id

FROM `share_dev_info` ;

####

SELECT pin,

(case

when avg(id)>10022 then 'new'

else 'old'

end ) AS DataID FROM `share_dev_info` GROUP BY pin;

####

SELECT st.id,

st.p_id AS pId,

st.flag AS mFlag

from st

join dev on

dev.p_id=st.p_id where

dev.id=10241;

####

SELECT st.id,

st.pid AS pId

from steam st,device dev

where

dev.p_id=st.p_id and

dev.id=10241;