开发者

Mysql: How to select distinct values from a database column

开发者 https://www.devze.com 2023-01-10 13:43 出处:网络
My goal is to select value from \"EmbedImgDimension\" column where in lots of duplicated values are present.

My goal is to select value from "EmbedImgDimension" column where in lots of duplicated values are present.

I have used the following query

select
  distinct EmbedImgId,
  VideoID,
  EmbedImgHeight,
  EmbedImgWidth,
  EmbedImgFileName,
  concat(embedimgwidth,' x ',embedimgheight) as EmbedImgDimension
  from embedimages
  inner join Video on Video.schoolid=#Value#
  where embedimages.isdeleted=0 order by embedimages.embedimgwidth asc;

wat modification should i make in this query so as to select unique values from t开发者_如何学Pythonhe "EmbedImgDimension" column.Any help would be deeply appreciated.

Thanks.


  select
  distinct concat(embedimgwidth,' x ',embedimgheight) as EmbedImgDimension
  from embedimages
  inner join Video on Video.schoolid=#Value#
  where embedimages.isdeleted=0 order by embedimages.embedimgwidth asc;

update

saying you also want distinct video ids is a logical problem. you want to get a result in which each dimension appears only once, right? then, how can you expect to also get all the distinct videoID results? imagine you have

videoid  dimension
      1        1x1
      2        1x1
      3        2x2
      4        2x2

maybe you can tell me which result you'd like to get. but you're either going to get 1x1 and 2x2, or you're going to get 1,2,3,4 - the moment you want dimension uniqueness, you can't also get all the distinct videoids, see what I mean?


Use the distinct keyword on the EmbedImgDimension column.

0

精彩评论

暂无评论...
验证码 换一张
取 消