Fork me on GitHub

常用sql语句

插入:

//sql插入语句
$query = "INSERT INTO table(name,openid) VALUES ('$name','$openid')";

查询:

//sql条件查询语句
 $query = "select * from table where ygh=$ygh and password=$pass";


//sql条件查询语句(获取相同字段最后一个id的一行数据)
$query = "select * from table where openid='$openid'  and id=(select max(id) from table where openid='$openid') ";


//sql条件修改语句(时间降序排列,可以把时间改为id)
 $query = "SELECT name,tx,ly,time FROM table ORDER BY time DESC";


//sql条件修改语句(时间升序排列,可以把时间改为id)
 $query = "SELECT name,tx,ly,time FROM table ORDER BY time ASC";


//sql条件修改语句(查询时间最新的15条数据,可以把时间改为id)
 $query = "SELECT  `tx` FROM table ORDER BY time DESC LIMIT 0 ,15";

修改:

//sql条件修改语句
 $query = "UPDATE table SET openid='$openid' ,password='$pass' WHERE ygh='$ygh'";

删除:

//sql删除语句
$query = "delete from table where id='$id'";

 

posted @ 2018-03-02 15:09  小白不白10  阅读(155)  评论(0编辑  收藏  举报