sql特殊语句

1.联表查询

  select * from zongyi zongyiitem where zongyi.id=zongyiitem.id

2.联表删除

  delete from zongyi ,zongyiitem where zongyi.id=zongyiitem.zongyiid  where zongyiid=10

3.联表更新

  update detail_youbian  dt inner join city_yb ct on dt.shi=ct.shi set dt.sheng=ct.sheng

4.查询当天零点时间戳

  SELECT UNIX_TIMESTAMP(DATE(NOW()))

5.查看数据保存位置

  show variables like '%datadir%'

6.为表添加某字段

  ALTER TABLE `zongyi` ADD `baike_url` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '百科url' AFTER `collecturl`

7.查询playtime中'周'出现的次数

  SELECT id from zongyi WHERE length(playtime) - length(replace(playtime,'周','')) >3

8.cast --把原来的格式转为指定的格式

  select CAST(play_time AS CHAR) as time from zongyiitem where zongyiid=10

未完待续...

上一篇:HTTP的RST包与WinHttp延迟关闭TCP连接


下一篇:服务器后台TCP连接存活问题