select help needed

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

select help needed

Post by pelegk2 »

i have a table with user name,user password,full name
and another table with buy_id,user name
know when i print to the screen the row with the buy_id
i donnt want to print the user name but his full name (which is on the other table!
how do i do that?
thanks in advance
peleg
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

for future ref, this is a db q and belongs in that forum.

try: SELECT buy_id,full_name FROM buy_table INNER LEFT JOIN ON user_table WHERE buy_table.user_name=user_table.user_name ...


btw: i don't use many joins, so you might wanna double check on sybtax and all before using that.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

As mentioned, you need a table join. But first you could maybe improve your db design a little by adding auto-incrementing integer ids. It's good practice to have a "meaningless" id for every row ie don't use an invoice number, NI number etc which, as well as being a row identifier, has additional meaning.

All, including JOINs, explained here http://www.oreilly.com/catalog/javadtab ... r/ch02.pdf
Post Reply