Solved

Unknown table in field list

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

770 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