CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Need help with SQL statment

  1. #1
    Join Date
    Sep 2006
    Posts
    28

    Need help with SQL statment

    Code:
    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
    	FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
    	WHERE p.topic_id = $topic_id
    		$limit_posts_time
    		AND pt.post_id = p.post_id
    		AND u.user_id = p.poster_id
    	ORDER BY p.post_time $post_time_order
    This is the current sql that I have, but I need to have it select:
    Code:
    SELECT e.member_race_id, e.member_class_id
    FROM eqdkp members
    WHERE e.member_id = u.user_eqdkpmem
    but the only problem is, I want it to return null for e.member_race_id and e.member_class_id, if there is no match

  2. #2
    Join Date
    Sep 2006
    Posts
    28

    Re: Need help with SQL statment

    I fixed it:
    Code:
    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_eqdkpmem, 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, j.member_id
    FROM `phpbb_posts` p, `phpbb_users` u, `phpbb_posts_text` pt,
    ( SELECT u.user_id, e.member_id, e.member_name, e.member_gender, e.member_level, e.member_class_id, e.member_race_id
    FROM `phpbb_users` u
    LEFT JOIN eqdkp_members e ON u.user_eqdkpmem = e.member_id)j
    WHERE p.topic_id = '3'
    AND pt.post_id = p.post_id
    AND u.user_id = p.poster_id
    AND u.user_id = j.user_id
    But I don't know if this is the most efficient way, if any1 has any suggestions please let me know.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)