• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Need some SQL help

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Need some SQL help

    I'd be forever grateful and would love to buy a pint or two for anyone who can help me out with this. I know zip about SQL.

    I have a web app using Postgres as the backend. I've installed phpPgAdmin on the web server so I can look but not touch anything in there.

    I want to do a simple listing of all the users but I need to query two tables, one holds the username, first and last names, the other holds email and home address etc.

    I know this is likely very simple to do but I haven't got a clue
    Me, me, me...

    #2
    Originally posted by Cliphead View Post
    I'd be forever grateful and would love to buy a pint or two for anyone who can help me out with this. I know zip about SQL.

    I have a web app using Postgres as the backend. I've installed phpPgAdmin on the web server so I can look but not touch anything in there.

    I want to do a simple listing of all the users but I need to query two tables, one holds the username, first and last names, the other holds email and home address etc.

    I know this is likely very simple to do but I haven't got a clue
    Presumably the username is used as a key in the table that holds the details? Or is there a numeric field, probably called "id", and a corresponding numeric field, probably called "user_id", in the second field?

    As those questions might suggest you really need to explicitly state what the structure of the tables is (and indeed their names), but this might get you started:

    Code:
    SELECT user.username, user.first_name, user.last_name, user_info.email
    FROM user, user_info
    WHERE user.id = user_info.user_id
    or, if the username is used as the key,

    Code:
    SELECT user.username, user.first_name, user.last_name, user_info.email
    FROM user, user_info
    WHERE user.username = user_info.username

    Comment


      #3
      Originally posted by NickFitz View Post
      Presumably the username is used as a key in the table that holds the details? Or is there a numeric field, probably called "id", and a corresponding numeric field, probably called "user_id", in the second field?

      As those questions might suggest you really need to explicitly state what the structure of the tables is (and indeed their names), but this might get you started:

      Code:
      SELECT user.username, user.first_name, user.last_name, user_info.email
      FROM user, user_info
      WHERE user.id = user_info.user_id
      or, if the username is used as the key,

      Code:
      SELECT user.username, user.first_name, user.last_name, user_info.email
      FROM user, user_info
      WHERE user.username = user_info.username
      Yes, the first example was bang on and got it working for me.

      You're a star Nick, I owe you for this one!
      Me, me, me...

      Comment


        #4
        Originally posted by Cliphead View Post
        Yes, the first example was bang on and got it working for me.

        You're a star Nick, I owe you for this one!
        HTH

        Comment


          #5
          Originally posted by NickFitz View Post
          HTH
          I sorta knew how the query should be structured but not the actual syntax. This stuff is a long way from Clipper

          Thanks again!
          Me, me, me...

          Comment


            #6
            Originally posted by Cliphead View Post
            I'd be forever grateful and would love to buy a pint or two for anyone who can help me out with this. I know zip about SQL.

            I have a web app using Postgres as the backend. I've installed phpPgAdmin on the web server so I can look but not touch anything in there.

            I want to do a simple listing of all the users but I need to query two tables, one holds the username, first and last names, the other holds email and home address etc.

            I know this is likely very simple to do but I haven't got a clue
            try "drop table user"

            HTH

            Comment


              #7
              Originally posted by BrilloPad View Post
              try "drop table user"

              HTH
              I already did that, the backup script worked
              Me, me, me...

              Comment


                #8
                Have you allowed for this?

                http://benajnim.com/index.php/php/sa...-input-in-php/

                Comment


                  #9
                  Originally posted by BrilloPad View Post
                  Excellent!
                  Me, me, me...

                  Comment


                    #10
                    Originally posted by Cliphead View Post
                    Excellent!
                    I sent this to the dbas at clientco - they did not so much as laugh. either they have seen it several times before or are humourless ****s

                    Comment

                    Working...
                    X