folder Tahribat.com Forumları
linefolder Database - Veritabanı
linefolder Her Unique ID'nin İlk Girdisini Sorgulamak



Her Unique ID'nin İlk Girdisini Sorgulamak

  1. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Daft Ground
    PLaXToR
    PLaXToR's avatar
    Kayıt Tarihi: 08/Temmuz/2003
    Erkek

    Selamlar, ufak bir sorum var:

    aşağıdaki şekilde olan bir veritabanım var unique id product id her ürünün idsini belirtiyor image ise o ürünün resmini belirtiyor.

    TABLO:

    product_id image
    453 catalog/product-images/001/IMG_0112.jpg
    453 catalog/product-images/001/IMG_0109.jpg
    452 catalog/product-images/001/IMG_0106.jpg
    452 catalog/product-images/001/IMG_0108.jpg
    452 catalog/product-images/001/IMG_0107.jpg
    451 catalog/product-images/001/IMG_0104.jpg
    451 catalog/product-images/001/IMG_0102.jpg
    451 catalog/product-images/001/IMG_0103.jpg
    450 catalog/product-images/001/IMG_0096.jpg
    450 catalog/product-images/001/IMG_0097.jpg
    450 catalog/product-images/001/IMG_0095.jpg
    449 catalog/product-images/001/IMG_0093.jpg
    449 catalog/product-images/001/IMG_0094.jpg
    449 catalog/product-images/001/IMG_0092.jpg
    448 catalog/product-images/001/IMG_0087.jpg
    448 catalog/product-images/001/IMG_0088.jpg
    448 catalog/product-images/001/IMG_0089.jpg
    447 catalog/product-images/001/IMG_0085.jpg
    447 catalog/product-images/001/IMG_0081.jpg
    447 catalog/product-images/001/IMG_0086.jpg
    446 catalog/product-images/001/IMG_0078.jpg
    446 catalog/product-images/001/IMG_0079.jpg
    446 catalog/product-images/001/IMG_0077.jpg
    445 catalog/product-images/001/IMG_0076.jpg
    445 catalog/product-images/001/IMG_0074.jpg
     

    Bir üründe 3-4 tane resim var ama ben ilk resimleri almak istiyorum. 

    Örnek: 

    451  catalog/product-images/001/IMG_0104.jpg
    452  catalog/product-images/001/IMG_0106.jpg
    453  catalog/product-images/001/IMG_0112.jpg
    ... ...

    gibi bir çıktı üretmesini istiyorum.

    Yardımcı olurmusunuz?

    PLaXToR tarafından 15/Oca/19 12:06 tarihinde düzenlenmiştir

    If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
  2. KısayolKısayol reportŞikayet pmÖzel Mesaj
    EmQceR
    EmQceR's avatar
    Kayıt Tarihi: 14/Kasım/2007
    Erkek

    Kullandığın veritabanının adı nedir ? Rowid ile işlem yapabilirsin düşüncesindeyim


    ...
  3. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Daft Ground
    PLaXToR
    PLaXToR's avatar
    Kayıt Tarihi: 08/Temmuz/2003
    Erkek

    MYSQL/MariaDB kullanıyorum hocam

    Distinct ile denedim olmadı.


    If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
  4. KısayolKısayol reportŞikayet pmÖzel Mesaj
    juniourfalcon
    juniourfalcon's avatar
    Kayıt Tarihi: 22/Mayıs/2012
    Erkek

    sorguya şunu eklemen lazım 

    ORDER BY id ASC

  5. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Daft Ground
    PLaXToR
    PLaXToR's avatar
    Kayıt Tarihi: 08/Temmuz/2003
    Erkek

    ORDER BY sadece sıralama yapar ve hiçbirşeyi değiştirmez hocam ben tekrar eden ID leri almak istemiyorum. Distinct ile yapılıyor ama bir column daha olduğu için aggregate/toplama vs gibi bir işlem yapmatığım için aynı şekilde geliyor.

    "tekrar etmeyen id" ler ile dolu herhangi bir "image" i almak istiyorm.


    If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
  6. KısayolKısayol reportŞikayet pmÖzel Mesaj
    Daft Ground
    PLaXToR
    PLaXToR's avatar
    Kayıt Tarihi: 08/Temmuz/2003
    Erkek

    Hallettim. İşinize yaraması için paylaşayım:

     

    SELECT 
    `product_id`, MIN(`image`) 
    FROM 
    `shop_product_image` 
    GROUP BY 
    `product_id`  
    ORDER BY `shop_product_image`.`product_id`  ASC

     


    If there are two or more ways to do something, and one of those ways can result in a catastrophe, then someone will do it.
Toplam Hit: 1196 Toplam Mesaj: 6
unique id il giridisi