0

inside a mysql table there are several classifieds with the rows ID, title, advertiser_id

In order to omit duplicated content inside my sitemap I am trying to retrieve a list where title and advertiser are unique.

My sql stmt looks like this:

SELECT distinct concat(cl.title, cl.advertiser_id) AS uniques, cl.ID ...

unfortunatelly this does not work as expected. The result looks like this:

uniques                                     ID      title   
Mobile Wellnessmassage ( Kreis Soest)58091  26608   Mobile Wellnessmassage ( Kreis Soest)
Mobile Wellnessmassage ( Kreis Soest)58091  24465   Mobile Wellnessmassage ( Kreis Soest)

Any ideas how I could restrict the result to a dataset with uniques?

Thank you for any help

merlin
  • 2,717
  • 3
  • 29
  • 59

1 Answers1

0

No, it works as it need to works. You are getting back 2 records, because ID is not the same. If you leave the cl.ID, you will get back only one record. Try it.

vaso123
  • 12,347
  • 4
  • 34
  • 64
  • this is true. But I also need cl.ID and other values. – merlin Oct 14 '14 at 21:42
  • you try to achive something, what you can not. `DISTINCT` means distinct. Let's use 2 queries. First for the `DISTINCT` things, second for the ID-s. – vaso123 Oct 14 '14 at 21:57