Author Topic: Display only the images with the identique image name (image_name)  (Read 7154 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Hi all,

I have a little request. I know it is simple, but my PHP knowledge did not allowed me to do that.

I want to display only the images with the duplicate image name (image_name) on an additional page.

Can someone improve this query for me please?

Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, i.image_postcards".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.image_name = ******** AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
GROUP BY i.image_name ASC
LIMIT 500

I appreciate the time you use to help me.

Thanks in advance,


Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Display only the images with the identique image name (image_name)
« Reply #1 on: December 22, 2008, 03:47:58 PM »
Hi all,

I solved it myself with this query code:

Code: [Select]
$sql = "SELECT COUNT(*) as nameID, i.image_name, i.image_id, i.cat_id, i.user_id, i.image_speler, i.image_youtube, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, i.image_postcards
FROM (".IMAGES_TABLE." i)
WHERE i.image_active = 1 AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
GROUP BY i.image_name
HAVING nameID > 1

Thanks anyway if you were trying to help me :wink:

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Display only the images with the identique image name (image_name)
« Reply #2 on: December 22, 2008, 05:26:14 PM »
I must misunderstood your request, because that query will only select images that have duplicates, and will not select the duplicates themselves..
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Display only the images with the identique image name (image_name)
« Reply #3 on: December 22, 2008, 05:33:10 PM »
Actually I wanted to have the query who select the duplicates themselves, but I could not. My PHP knowledge is very poor.

I will be grateful if you have the other query for me.

Offline V@nо

  • Addicted member
  • ******
  • Posts: 1.223
    • View Profile
Re: Display only the images with the identique image name (image_name)
« Reply #4 on: December 22, 2008, 06:55:45 PM »
I was curious about this myself but couldn't find anything on google, so I asked at mysql.com forum. Someone answered with working query, however when I tryed it on database with 300k images it timed out.
Try search on that site for "select duplicate", I can't show direct link to the topic at the moment.
Your first three "must do" before you ask a question:
If I asked you to PM me, I meant PM to my primary account, this account doesn't accept PMs.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Display only the images with the identique image name (image_name)
« Reply #5 on: December 22, 2008, 06:59:43 PM »
Thanks V@no. I will.

I will inform you when I know more :wink:

Thank you for your try.

Offline Guldstrand

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Display only the images with the identique image name (image_name)
« Reply #6 on: June 16, 2011, 12:48:45 AM »
I´m looking for a similar mod. Any progress?