1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

inner join

Discussion in 'MySQL' started by reflex073, Dec 16, 2012.

  1. #1
    hi all. i from turkey. my english is very bad. too sorry all. i have a this problem; i have 2 table. first and second. i want to secont just one listing.


    $rilana = mysql_query("SELECT * FROM ilanlar INNER JOIN resimler ON ilanlar.id=resimler.emlak WHERE durumu=1 and yayin=1 or yayin=5 and NOW()<=bittarih order by RAND()");





    turkish resim english photos. emlak is english estate. every estate have lot of photos. but i want listing every estate with just one photo.
     
    reflex073, Dec 16, 2012 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Your English isn't that bad.

    ilanlar.id=resimler.emlak
    ilanlar.id has to be the same data type (integer, char, etc.) as resimler.emlak.

    bittarih has to be a date in the proper format (see the manual).
    Date with no time is the beginning of the day - 00:00:00.

    Did you mean
    WHERE (durumu=1 and (yayin=1 or yayin=5) and NOW()<=bittarih)
    or
    WHERE (durumu=1 and yayin=1) or (yayin=5 and NOW()<=bittarih)
    or
    WHERE (((durumu=1 and yayin=1) or yayin=5) and NOW()<=bittarih)
    you have to be specific with these fields to be sure that you get what you want.
     
    Rukbat, Dec 20, 2012 IP
  3. reflex073

    reflex073 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    this one

    WHERE (durumu=1 and (yayin=1 or yayin=5) and NOW()<=bittarih)


    and i want
    added to the (join table) table limit 1
     
    reflex073, Dec 20, 2012 IP
  4. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #4
    $rilana = mysql_query("SELECT * FROM ilanlar INNER JOIN resimler ON ilanlar.id=resimler.emlak WHERE (durumu=1 and (yayin=1 or yayin=5) and NOW()<=bittarih) order by RAND()");

    Not that complicated.
     
    Rukbat, Dec 20, 2012 IP