?
Solved

Unknown table in field list

Posted on 2007-12-05
3
Medium Priority
?
1,654 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article discusses how to implement server side field validation and display customized error messages to the client.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
The viewer will learn how to count occurrences of each item in an array.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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