not unique table alias error

Posted on 2005-05-12
Last Modified: 2008-03-10
Anyone know what would be causing this 'not unique table/alias' error?

ODBC Error Code = S1000 (General error)

[MySQL][ODBC 3.51 Driver][mysqld-4.0.24-nt]Not unique table/alias: 'articles'

SQL = "SELECT Category.acatid, Category.acategory, articles.writerid, articles.articleid, articles.articledate, articles.summary, articles.title, articles.words, articles.atype, articles.payonly, articles.requests, writers.fname, writers.lname FROM articles, writeres, Category INNER JOIN (writers INNER JOIN articles ON writers.writerid = articles.writerid) ON Category.acatid = articles.acatid WHERE articles.words>-1 AND category.acategory Like 'Business%' AND articles.articledate>Now()-8 ORDER BY articles.requests DESC, articles.articledate DESC"

Question by:bluskyGuy
    1 Comment
    LVL 5

    Accepted Solution

    Hi Rick,

    It appears that you reference the table "articles" twice.  You need to alias one of them to avoid ambiguity.  

    SELECT ...
    FROM *articles*, writeres, Category
    INNER JOIN (writers INNER JOIN *articles* ON writers.writerid = articles.writerid) ON Category.acatid = articles.acatid
    WHERE ...

    I'm a little confused by the syntax after the INNER JOIN clause...should it really be something like

    SELECT ...
    FROM articles, writeres, Category
    INNER JOIN (SELECT * FROM writers INNER JOIN articles ON writers.writerid = articles.writerid) x ON Category.acatid = x.acatid
    WHERE ...


    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (…
    Foreword This is an old article.  Instead of using the MySQL extension that was used in the original code examples, please choose one of the currently supported database extensions instead.  More information is available here: MySQLi / PDO (http://…
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    18 Experts available now in Live!

    Get 1:1 Help Now