Need help with Left Join (MySQL)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MichaelP
    Registered User
    • Aug 2003
    • 7124

    #1

    Need help with Left Join (MySQL)

    Hey guys, I'm doing a bit of clean up in my stuff and I,m bulilding a new tool to manage my banners...

    Here is what I try to accomplish (I know it's easy for a real programmer, which I'm not and never pretended to be)

    Table programs : id , name ( ex : 22 , BabesMoney) ... +++

    Table banner : id , program_id , site, (ex : 1 , 22 , Babes.Com) ... +++

    Now here is the query which I play with... Not working but I know I'm close.. The query itself is pretty self explanatory

    Code:
    $query = "SELECT banner.*, programs.* FROM banner LEFT JOIN programs ON (program_id = programs.id, program = programs.program,) WHERE  blah, blah blah, meh meh meh... ";
    So on the print, I want Program = BabesMoney instead of just 22

    Thank in advance
    Last edited by MichaelP; 10-20-2012, 07:14 AM.
  • Vapid - BANNED FOR LIFE
    Barterer
    • Aug 2004
    • 4864

    #2
    databases are matrices.

    Comment

    • MichaelP
      Registered User
      • Aug 2003
      • 7124

      #3
      Originally posted by pornopete
      You're probably better off hiring somebody than spending your time on this.
      Well I'd do this if I couldn't do any of it, but now I'm stuck on a simple query, so I won't hire a programmer for a single line of code ...

      Comment

      • donborno
        Confirmed User
        • Jan 2007
        • 374

        #4
        SELECT banner.id, programs.name, banner.site
        FROM banner
        LEFT JOIN programs ON banner.program_id = programs.id
        WHERE blah, blah blah, meh meh meh...

        Probably it's an INNER JOIN unless you have banners which do not reference a program

        Comment

        • MichaelP
          Registered User
          • Aug 2003
          • 7124

          #5
          Originally posted by donborno
          SELECT banner.id, programs.name, banner.site
          FROM banner
          LEFT JOIN programs ON banner.program_id = programs.id
          WHERE blah, blah blah, meh meh meh...

          Probably it's an INNER JOIN unless you have banners which do not reference a program
          Not quite but Txs.

          hey May I hire you for an hour or so? I can pay Paypal... I have a good name here and I want to keep it. Hit me up on ICQ pls @ 139036653

          Comment

          • woj
            <&(©¿©)&>
            • Jul 2002
            • 47882

            #6
            Originally posted by MichaelP
            Not quite but Txs.

            hey May I hire you for an hour or so? I can pay Paypal... I have a good name here and I want to keep it. Hit me up on ICQ pls @ 139036653
            If the other guy is busy, icq me: 33375924, I can help out..
            Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
            Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
            Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

            Comment

            • sarettah
              see you later, I'm gone
              • Oct 2002
              • 14301

              #7
              $query = "SELECT banner.*, programs.* FROM banner LEFT JOIN programs ON (program_id = programs.id, program = programs.program,)

              Do you actually have that comma before the close paren in there. Because that will screw it for you.

              .
              All cookies cleared!

              Comment

              • MichaelP
                Registered User
                • Aug 2003
                • 7124

                #8
                Originally posted by woj
                If the other guy is busy, icq me: 33375924, I can help out..
                Thank you Woj for the nice help

                Was very fast and effective. Will take yu for work again for sure.

                A+

                Comment

                • sarettah
                  see you later, I'm gone
                  • Oct 2002
                  • 14301

                  #9
                  Originally posted by MichaelP
                  Thank you Woj for the nice help

                  Was very fast and effective. Will take yu for work again for sure.

                  A+
                  Can't go wrong with WOJ

                  .
                  All cookies cleared!

                  Comment

                  • Bad18yroldvirginteens
                    So Fucking Banned
                    • Oct 2012
                    • 116

                    #10
                    man complicated

                    Comment

                    • Lace
                      Too lazy to set a custom title
                      • Mar 2004
                      • 16116

                      #11
                      Originally posted by sarettah
                      Can't go wrong with WOJ

                      .
                      I've had friends hire WOJ before and he's always been great!
                      Your Paysite Partner
                      Strength In Numbers!
                      StickyDollars | RadicalCash | KennysPennies | HomegrownCash

                      Comment

                      • Kiopa_Matt
                        Confirmed User
                        • Oct 2007
                        • 1448

                        #12
                        Code:
                        SELECT banner.id AS banner_id, banner.program_id AS program_id, programs.site AS site_name FROM banner, programs WHERE banner.program_id = programs.id;
                        You have three columns returned -- banner_id, program_id, site_name.
                        xMarkPro -- Ultimate Blog Network Management
                        Streamline your marketing operations. Centralize management of domains, pages, Wordpress blogs, sponsors, link codes, media items, sales and traffic statistics, plus more!

                        Comment

                        • seeme
                          Stephen
                          • Jun 2011
                          • 840

                          #13
                          Originally posted by Kiopa_Matt
                          Code:
                          SELECT banner.id AS banner_id, banner.program_id AS program_id, programs.site AS site_name FROM banner, programs WHERE banner.program_id = programs.id;
                          You have three columns returned -- banner_id, program_id, site_name.

                          Comment

                          Working...