Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 960665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:13:05+00:00 2026-05-16T01:13:05+00:00

The error I’m getting is: Not unique table/alias: ‘favourites’ I apologise for the reasonably

  • 0

The error I’m getting is:

Not unique table/alias: ‘favourites’

I apologise for the reasonably intense query(!):

    SELECT code.id AS codeid, code.featured AS featured, code.title AS codetitle, code.summary AS codesummary, code.author AS codeauthor, code.date, code.challengeid,
    ratingItems.*, FORMAT((ratingItems.totalPoints / ratingItems.totalVotes), 1) AS rating,
    code_tags.*, tags.*,
    users.firstname AS authorname, users.id AS authorid,
    GROUP_CONCAT(tags.tag SEPARATOR ', ') AS taggroup,
    COUNT(DISTINCT comments.codeid) AS commentcount,
    favourites.id, favourites.code_id, favourites.user_id

    FROM (code)
    JOIN code_tags ON code_tags.code_id = code.id
    JOIN tags ON tags.id = code_tags.tag_id
    JOIN users ON users.id = code.author
    LEFT JOIN comments ON comments.codeid = code.id
    LEFT JOIN ratingItems ON uniqueName = code.id
    LEFT JOIN favourites ON favourites.user_id = 10
    LEFT JOIN favourites ON favourites.code_id = code.id

    GROUP BY code_id
    ORDER BY date desc

What am I doing wrong? I really can’t understand it…

Thanks!

Jack

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:13:06+00:00Added an answer on May 16, 2026 at 1:13 am

    I guess that you only want to join with the favourites table once but with two conditions. If so use this:

    LEFT JOIN favourites ON  favourites.user_id = 10
                         AND favourites.code_id = code.id
    

    If you do actually want to join with this table twice then you need to give it two different aliases:

    LEFT JOIN favourites f1 ON f1.user_id = 10
    LEFT JOIN favourites f2 ON f2.code_id = code.id
    

    Then in the SELECT list you instead of favourites you need to use either f1 or f2 as appropriate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Error: Database table users for model User was not found. I'm expriencing the error
Error SQL query: LOAD DATA LOCAL INFILE '/home/sharma/Desktop/New.txt' INTO TABLE FIELDS FIELDS TERMINATED BY
Error: org.hibernate.LazyInitializationException SEVERE: could not initialize proxy - the owning Session was closed Code:
Error: End tag for 'optgroup' which is not finished. You have probably failed to
Error % javac StringTest.java StringTest.java:4: variable errorSoon might not have been initialized errorSoon[0] =
error C2784: 'std::basic_ostream<_Elem,_Traits> &std::operator <<(std::basic_ostream<_Elem,_Traits> &,const std::basic_string<_Elem,_Traits,_Alloc> &)' : >could not deduce template argument
Error: Could not load System.Data.SqlServerCe.Entity.dll. Reinstall SQL Server Compact. Inner Exception: {Could not load
Error Details: The Web application at http://dev001aaamaaind:333/ could not be found. Verify that you
Error 3 Running transformation: System.ArgumentException: Format of the initialization string does not conform to
Error im getting: An unhandled exception of type 'System.StackOverflowException' occurred in System.Management.dll My callstack:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.