Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unknown table in field list

Posted on 2007-12-05
3
Medium Priority
?
1,667 Views
Last Modified: 2013-12-12
I am having an issue where MySQL is coming back and saving I have an unknown table in field list.

Here is my sql:
Invalid SQL:

            SELECT
                  post.*, post.username AS postusername, post.ipaddress AS ip, IF(post.visible = 2, 1, 0) AS isdeleted,
                  user.*, userfield.*, usertextfield.*,
                  icon.title as icontitle, icon.iconpath,
                  avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline,customavatar.width AS avwidth,customavatar.height AS avheight,
                  deletionlog.userid AS del_userid, deletionlog.username AS del_username, deletionlog.reason AS del_reason,
                  editlog.userid AS edit_userid, editlog.username AS edit_username, editlog.dateline AS edit_dateline,
                  editlog.reason AS edit_reason,
                  postparsed.pagetext_html, postparsed.hasimages,
                  sigparsed.signatureparsed, sigparsed.hasimages AS sighasimages,
                  sigpic.userid AS sigpic, sigpic.dateline AS sigpicdateline, sigpic.width AS sigpicwidth, sigpic.height AS sigpicheight,
                  IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
                  
                  ,blog_user.entries,m_badgecount.count
            FROM post AS post
            LEFT JOIN user AS user ON(user.userid = post.userid)
            LEFT JOIN userfield AS userfield ON(userfield.userid = user.userid)
            LEFT JOIN usertextfield AS usertextfield ON(usertextfield.userid = user.userid)
            LEFT JOIN icon AS icon ON(icon.iconid = post.iconid)
            LEFT JOIN avatar AS avatar ON(avatar.avatarid = user.avatarid) LEFT JOIN customavatar AS customavatar ON(customavatar.userid = user.userid)
                  LEFT JOIN deletionlog AS deletionlog ON(post.postid = deletionlog.primaryid AND deletionlog.type = 'post')
            LEFT JOIN editlog AS editlog ON(editlog.postid = post.postid)
            LEFT JOIN postparsed AS postparsed ON(postparsed.postid = post.postid AND postparsed.styleid = 4 AND postparsed.languageid = 1)
            LEFT JOIN sigparsed AS sigparsed ON(sigparsed.userid = user.userid AND sigparsed.styleid = 4 AND sigparsed.languageid = 1)
            LEFT JOIN sigpic AS sigpic ON(sigpic.userid = post.userid)
                  LEFT JOIN blog_user AS blog_user ON (blog_user.bloguserid = post.userid)
LEFT JOIN m_badgecount AS badge_count ON (m_badgecount.userid = post.userid)
            WHERE post.postid IN (0,13416,13425,13436)
            ORDER BY post.dateline;

MySQL Error  : Unknown table 'm_badgecount' in field list
Error Number : 1109

I know the table exists...as I can select * from it in a sql window.

Everything works if I remove the m_badgecount.count from the select area and the LEFT JOIN m_badgecount AS badge_count ON (m_badgecount.userid = post.userid) from the join area.
0
Comment
Question by:DragonByte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
fibo earned 2000 total points
ID: 20411895
Since you said
 m_badgecount AS badge_count
I would guess that
                  IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
                 
                  ,blog_user.entries,m_badgecount.count
            FROM post AS post

should be
                  IF(displaygroupid=0, user.usergroupid, displaygroupid) AS displaygroupid, infractiongroupid
                 
                  ,blog_user.entries,badgecount.count
            FROM post AS post
0
 
LVL 1

Author Comment

by:DragonByte
ID: 20412012
You are correct...and the ON clause needed badge_count: ON (badge_count.userid...


I don't know how I messed that one up.  Thanks a million.
0
 
LVL 29

Expert Comment

by:fibo
ID: 20412095
Glad to help!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question