zoukankan      html  css  js  c++  java
  • mysql_query

    _______________________批量修改MySQL表前缀名称
    ALTER TABLE ssc__played RENAME TO ssc_played;
    ALTER TABLE ssc__played_group RENAME TO ssc_played_group;
    ALTER TABLE ssc__score_goods RENAME TO ssc_score_goods;
    ALTER TABLE ssc__score_swap RENAME TO ssc_score_swap;
    ALTER TABLE ssc__sysadmim_session RENAME TO ssc_sysadmim_session;
    ALTER TABLE ssc__sysadmin_bank RENAME TO ssc_sysadmin_bank;
    ALTER TABLE ssc__sysadmin_session RENAME TO ssc_sysadmin_session;
    ALTER TABLE ssc__sysmember RENAME TO ssc_sysmember;
    ALTER TABLE ssc__type RENAME TO ssc_type;
    
    select table_name FROM information_schema.tables;
    select table_name FROM information_schema.tables where table_name like 'xy_%';
    Select CONCAT( 'ALTER TABLE ', table_name, ' RENAME TO ssc', substring(table_name,5 ),';' )FROM information_schema.tables Where table_name LIKE 'ssc_%';
    
    
    @$con=mysql_connect("localhost","root","");
    mysql_select_db("abc",$con);
    mysql_query("set names utf8");
    //$sql="update user set agent_id=4 where id = 11";
    //$sql="insert into user (agent_id) VALUES ('4')";
    $sql="delete from user where id = 10537";
    $sql2="select agent_id from user where id = 11 limit 1";
    $rs=query($sql);
    $rs2=query($sql2);
    
    

    SELECT DATE_FORMAT( deteline, "%Y-%m-%d %H" ) , COUNT( * ) 
    FROM test

    GROUP BY DATE_FORMAT( deteline, "%Y-%m-%d %H" ) 

    查询某天:

    deteline, "%Y-%m-%d

    某时:

    deteline, "%Y-%m-%d %H"

    依次类推。

    其实就是对dateline进行处理,然后再对处理后的数据分组




    function query($sql){
    if(strstr($sql,"select")){
    $rs=mysql_query($sql);
    $res=array();
    while($row=mysql_fetch_assoc($rs)){
    array_push($res,$row);
    }
    return $res;
    }elseif(strstr($sql,"update")){
    $rs=mysql_query($sql);
    return $rs;
    }elseif(strstr($sql,"insert")){
    mysql_query($sql);
    $rs=mysql_insert_id();
    return $rs;
    }elseif(strstr($sql,"delete")){
    $rs=mysql_query($sql);
    return $rs;
    }

    }
    echo "<pre>";var_dump($rs);var_dump($rs2);exit;
    
    
    static public function Insert( $table, $condition )
    {
    self::Instance();

    $sql = "INSERT INTO `$table` SET ";
    $content = null;

    foreach ( $condition as $k => $v )
    {
    $v_str = null;
    if ( is_numeric($v) )
    $v_str = $v;
    else if ( is_null($v) )
    $v_str = 'NULL';
    else
    $v_str = "'" . self::EscapeString($v) . "'";

    $content .= "`$k`=$v_str,";
    }

    $content = trim($content, ',');
    $sql .= $content;

    $result = self::Query ($sql);
    if ( false==$result )
    {
    self::Close();
    return false;
    }

    return self::GetInsertId();
    }
  • 相关阅读:
    核心数据类型
    Python入门
    [多校联考2019(Round 4 T2)][51nod 1288]汽油补给(ST表+单调栈)
    [Codeforces 1228E]Another Filling the Grid (排列组合+容斥原理)
    [luogu5339] [TJOI2019]唱、跳、rap和篮球(容斥原理+组合数学)(不用NTT)
    用生成函数推导数列的通项公式
    [Luogu 5465] [LOJ 6435] [PKUSC2018]星际穿越(倍增)
    [BZOJ4569] [Luogu 3295] [SCOI2016]萌萌哒(并查集+倍增)
    [BZOJ4444] [Luogu 4155] [LOJ 2007] [SCOI2015]国旗计划(倍增)
    倍增好题记录
  • 原文地址:https://www.cnblogs.com/csjoz/p/7243901.html
Copyright © 2011-2022 走看看