Solved

Unknown table in field list

Posted on 2007-12-05
3
1,605 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now