Home > Database > Mysql Tutorial > sql 查询复数据并显示语句

sql 查询复数据并显示语句

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:47:27
Original
953 people have browsed it

sql 查询复数据并显示语句

sql 查询复数据并显示语句
 
 //方法二
 

 select name,content,imgurl,synois from (
select name,content,imgurl,synopsis ,row_number() over (partition by name order by content) as rn
from table1
) t where t.rn=1


//方法二

if object_id('[tb]') is not null drop table [tb]
create table [tb]([name] varchar(1),[content] varchar(5),[imgurl] varchar(5),[synopsis] varchar(6))
insert [tb]
select 'a','不同1','不同1','可不填' union all
select 'a','不同2','不同2','可不填' union all
select 'a','不同3','不同3','可不填' union all
select 'b','不同4','不同4','可不填' union all
select 'b','不同5','不同5','可不填' union all
select 'c','不同6','不同6','可不填'

select * from [tb]

with tt
as(
select id = row_number() over (partition by name order by name ),* from tb )

select  [name], [content], imgurl, synopsis from tt where id  = 1

Related labels:
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
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template