Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Going out on a limb here without the error message but my assumption is that you need an alias in front of your non-aliased column.</p> <p>You may also have a problem titling the view as new. This is a problem with using a generic name for a view or table. Try giving it a distinct name that matters. I'll use msThreadPosts as an example.</p> <pre><code>CREATE VIEW msThreadPosts AS SELECT msthread.id, msthread.threadname, Count(msthread.threadname) AS TotalPost, msposts.threadcategory --Not sure if you want msposts or msthread just pick one FROM msthread LEFT OUTER JOIN msposts ON msthread.threadname = msposts.threadname GROUP BY msthread.id, msthread.threadname, msthread.threadcategory </code></pre> <p>As long as we are looking at this query lets fix some other things that are being done in a silly way. </p> <p>Lets start off with aliasing. If you alias a column you can very easily make your query easy to understand and read to anyone who is inclined to read it.</p> <pre><code>CREATE VIEW msThreadPosts AS SELECT mt.id, mt.threadname, Count(mt.threadname) AS TotalPost, mp.threadcategory FROM mtas mt LEFT OUTER JOIN msposts mp ON mt.threadname = mp.threadname GROUP BY mt.id, mt.threadname, mt.threadcategory </code></pre> <p>There now doesn't that look better. </p> <p>The next thing to look as if your column names. msthread has an id column. That column name is incredibly generic. This can cause problems when a column isn't aliased and an id exists in mulitple places or there are muliple id columns. Now if we change that column name to <code>msthreadID</code> it makes things much clearer. The goal is to design your tables in a way that anyone working on your database can imidiatley tell what a column is doing.</p> <p>The next thing to look at is your join. Why are you joining on thread name? <code>threadname</code> is likely a character string and therefore not terribly efficient for joins. if <code>msthread</code> as an id column and needs to be joined to <code>msposts</code> then shouldn't <code>msposts</code> also have that id column to match up on to make joins more efficient?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload