Solved

Unknown table in field list

Posted on 2007-12-05
3
1,639 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
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
fibo earned 500 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 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