Home > Database > Mysql Tutorial > mysql 常用查询

mysql 常用查询

WBOY
Release: 2016-06-07 15:34:22
Original
1305 people have browsed it

一.group_concat函数,以指定的分割符合并列,与group by 一起用 例:SelectGROUP_CONCAT(c.columnName SEPARATOR ',') GROUP BY 二.PreparedStatement.RETURN_GENERATED_KEYS 得到刚刚插入记录的id PreparedStatementps .setXXX …… …… ps.executeUpdate(

一.group_concat函数,以指定的分割符合并列值,与group by 一起用

例:Select>GROUP_CONCAT(c.columnName SEPARATOR ',') >GROUP BY>

二.PreparedStatement.RETURN_GENERATED_KEYS   得到刚刚插入记录的id

PreparedStatement>ps.setXXX

……

……

ps.executeUpdate();
ResultSet>

rs.next();
int>


三.分页查询,得到查询的总条数

select SQL_CALC_FOUND_ROWS *>

ps =>           rs.next();
           int>


四、常见sql命令

<span>DROP TABLE IF </span><span>EXISTS </span><span>`user`;
CREATE TABLE `user` (
  `uid` int(11) NOT NULL </span><span><span>auto_increment</span></span><span>primary key,</span><span>
  `gid` int(11) </span><span>default </span><span>NULL,
  `username` varchar(15) NOT NULL,
  `password` varchar(15) NOT NULL,
</span>
Copy after login
<span><span>foreign key</span><span> (parent_id)  </span><span>reference </span><span>parent(id) </span></span><span>ON DELETE </span><span>cascade </span><span>on></span>
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template