Helpful Information
 
 
Category: MySQL
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

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

would doing that chnage how i would acess the info once its retrived?










privacy (GDPR)