Home > Database > Mysql Tutorial > SQL 实用语句

SQL 实用语句

WBOY
Release: 2016-06-07 17:58:20
Original
865 people have browsed it

以下的sql语句都以上面表mytable为准

id name
1 a
2 b
3 c
1 a
2 b
3 c

以下的sql语句都以上面表mytable为准:

1、查询id=1,3记录的所有数据
代码如下:
select * from mytable where id in(1,3)

2、删除id重复的数据,表中数据只剩下id=1,2,3的所有数据
代码如下:
select * into # from mytable
truncate table mytable

insert table select distinct * from #
select * from table
drop table #

3、创建一个新表 films_recent ,它的值包含来自表films
代码如下:
SELECT * INTO films_recent FROM films
Related labels:
sql
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