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 6240919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:39:40+00:00 2026-05-24T11:39:40+00:00

here is my query: SELECT * FROM (SELECT messages.*, users.* FROM `afo_messages` as messages

  • 0

here is my query:

SELECT * FROM 
   (SELECT messages.*, 
   users.* 
   FROM `afo_messages` as messages 
   INNER JOIN `key_users` as users ON messages.user_id = users.id 
   WHERE messages.category_id=5 
   ORDER BY messages.id DESC LIMIT 30) ilv 
ORDER BY messages.id ASC

Error is “#1060 – Duplicate column name ‘id'”.

Table afo_messages columns:

id | user_id | category_id | parent_id | message | create_date | update_date | status

Table key_users columns:

id | name | email | phone | pwd | active | role | invite_id | download_link | date

What I’m doing wrong?

Thanx!

  • 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-24T11:39:42+00:00Added an answer on May 24, 2026 at 11:39 am

    Pretty sure that when you run the inner query, the result set has two columns called ID (on from messages, one from users); you’re then running a query on that subquery, and the parser doesn’t understand it.

    Try:

    SELECT * FROM 
    (SELECT messages.id as message_id,
           messages.user_id, 
           ....all other columns from messages
    
           users.id as real_user_id, 
           users.name, 
           ..... all other columns from users
    FROM `afo_messages` as messages 
    INNER JOIN `key_users` as users ON messages.user_id = users.id 
    WHERE messages.category_id=5 
    ORDER BY messages.id DESC LIMIT 30) ilv 
    ORDER BY message_id ASC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$sql = SELECT messages.text, users.name FROM messages INNER JOIN users ON messages.user_id=users.id ORDER BY
Here is my code: mysql_query(SELECT * FROM messages WHERE to_user_id = '$user_id' GROUP BY
Here is my query Select Gender from Table The result pane shows 1 1
Here is my Query : select EmployeeName, EmployeeSalary from Employee2 for xml path('EmployeeDetails') returns
So here is the original query SELECT SUM(PickQty), SUM(ReqQty), AssignmentID, StopID FROM PickRequest GROUP
Here is the pseudo-code for my inline query in my code: select columnOne from
Here is the query that I am working on: SELECT `unitid`, `name` FROM apartmentunits
Here is my LINQ query: (from o in entities.MyTable orderby o.MyColumn select o.MyColumn).Distinct(); Here
We have a Union Query. Here's a basic (similar) example: SELECT a.Name, b.Info FROM
$query = mysql_query(SELECT *, MAX(date_time) FROM messages WHERE user_to='$current_user' OR user_from='$current_user' GROUP BY conversation

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.