MySQL Forums
Forum List  »  Newbie

MYSQL query question
Posted by: Joe Sweet
Date: June 02, 2005 03:12AM

Hello, i have two tables, one that holds some info for EVERY member of my messageboad (phpbb), that table looks like this:

---------------------
table phpbb_users:
id: 1, name="name", much_more="data"...
---------------------

this table contains info for EVERY member of the board. Plus i have one table that holds additional data for SOME members, ie:

---------------------
phpbb_batlerecord:
id: 78, won=4, lost=0, more_data...
id: 189, won=4, lost=0, more_data...
---------------------

but it does NOT have a row for EVERY member, just for some special.

Now i wanted to execute this statement:

---------------------
"SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar,
u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid, <b>br.won, br.lost</b>
FROM phpbb_posts p, phpbb_users u, phpbb_posts_text pt, phpbb_batlerecord br
WHERE p.topic_id = 487
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
AND br.user_id = p.poster_id
ORDER BY p.post_time DESC
LIMIT 0, 10"
---------------------

But it will only return rows for members that are in BOTH tables.

Is there any way (outer/inner/whatever join) that the statement returns a row for every member, even if the member is not in "phpbb_batlerecord" and that it sets the fields from "phpbb_batlerecord" to some value (undef, NULL, 0) for members that do not have any data in the "phpbb_batlerecord" table?

Please help me because I'm quite a newbie in MySQL.

Thanks, J.Sweet

Options: ReplyQuote


Subject
Written By
Posted
MYSQL query question
June 02, 2005 03:12AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.