views:

32

answers:

2

Hi friends, 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 the "EmbedImgDimension" column.Any help would be deeply appreciated.

Thanks.

+1  A: 

Use the distinct keyword on the EmbedImgDimension column.

thelost
can u explain to me the modification that has to be made in the current query
jithin
e.g. `select distinct (concat ("test", col_name)) from table_name`
thelost
@thelost: thanks.. let me try it out
jithin
+2  A: 
  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?

Nicolas78
if you want to get distinct values, you have to remove the non-distinct values (like video_ids). the way you put it now, the database tries to find distinct combinations of video_id, EmbedImgId, and so on (which are probably unique so you won't get any groupings)
Nicolas78
@nicolas78: thanks pal... but i also need to implement select distinct EmbedImgId, VideoID, EmbedImgHeight, EmbedImgWidth, EmbedImgFileName in my query... so wat can be done...
jithin
check out my update. I think you want the logically impossible but maybe you can elaborate further
Nicolas78
prly you just need several queries.
Nicolas78