Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting Past an Ambiguous Field

    I am making a news script that loads all the news for the site from the forum.
    however, i have run into a problem.
    the posts are stored in 2 tables,
    ccphpbb_posts has the post time, authors, forum id, and such.
    ccphpbb_posts_text has the post subjects and messages.

    heres my problem, both tables have a feild called post_id, which has the id number for the post, but since there are 2 of the same filed in the query it causes an error with says DBD::mysql::st execute failed: Column: 'post_id' in field list is ambiguous

    anyone have any idea how to get around that?

    heres my query (note: im using perl)
    SELECT post_id, forum_id, poster_id, post_time, post_subject, post_text, user_id, username, user_rank, user_avatar, user_sig FROM ccphpbb_posts, ccphpbb_posts_text, ccphpbb_users WHERE ccphpbb_posts.post_id=ccphpbb_posts_text.post_id ORDER BY post_id DESC

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    In your SELECT statement you need to identify from which table you wish to select that particular field

    SELECT ccphpbb_posts.post_id, ccphpbb_posts_text.post_id
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    would doing that chnage how i would acess the info once its retrived?
    The distance between insanity and genius is measured only by success!


  •  

    Posting Permissions

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