• 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

Cliphead

Pilchard
Thanks received
12
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
 
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
 
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! :yay:
 
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
 

Advertisers

Back
Top