当前位置: 代码迷 >> MySQL >> mysql语句相干操作
  详细解决方案

mysql语句相干操作

热度:117   发布时间:2016-05-05 16:45:25.0
mysql语句相关操作

记录下常用的mysql语句

1. 查询:select * from table where id = '1' order by id desc limit 0,20;

2. 更新:update table set name = ? where id = ?;

?????????????? PreparedStatement pstmts = conn.prepareStatement(sql);
?????????????? pstmts.setString(1, "xiaozhang");
?????????????? pstmts.setString(2, id);
?????????????? pstmts.executeUpdate();

3. 过滤查到的重复数据:select * from table where id = '1' group by name;

4. 2张表中根据关联字段合并一个临时表查询:select table1.name, table1.age, table2.num from table left join table2 on table1.name = table2.name where table1.name = 'xiaohua';

5. 插入新增数据:insert into table (name, age) values('xiaohua', '20');

  相关解决方案