extract from 2 tables but have missing data

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
juls
Forum Newbie
Posts: 6
Joined: Sat Mar 06, 2004 3:01 am

extract from 2 tables but have missing data

Post by juls »

Hi,

should be easy...but battling.

I want to print the data from two mysql tables in a html table. I want to print everything from table_1 (username and nickname). And if I have their email address in table_2, I want to print that in the same row in the html table. The two tables have the common field userID. But table_2 does not have email addresses for all users. This is where I'm having problems.

I am able to either print the info for users who's email address are in table_2, or I end up printing duplicates of users in table_1.

How can I neatly print the user info and their email address when it is present?
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

use an outer join for the sql statement and make the combined recordset one line for each user


show your code
juls
Forum Newbie
Posts: 6
Joined: Sat Mar 06, 2004 3:01 am

Post by juls »

Thanks, lostboy. I did some research on outer joins and it works!
Post Reply