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

  • Home
  • SEARCH
  • 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 8585147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:59:18+00:00 2026-06-11T21:59:18+00:00

I want to use multiple table to get recent post (Q) and user name

  • 0

I want to use multiple table to get recent post (Q) and user name (handle) but when I am trying to get with this code it is giving error

Table Name qa_posts and qa_users and need to connect userid from qa_posts to handle from qa_users

SELECT *
FROM qa_posts, qa_users
WHERE type="Q" AND qa_posts.userid = "qa_users.handle"
ORDER BY created DESC
LIMIT 5

Error message

SELECT *
FROM qa_posts, qa_users
WHERE qa_posts.userid = "qa_users.handle"
ORDER BY created DESC
LIMIT 5

Error 1052: Column 'created' in order clause is ambiguous

Actual Code

qa_db_connection();
$query_post = qa_db_query_raw('         
    SELECT *
    FROM qa_posts, qa_users
    WHERE type="Q" AND qa_posts.userid = "qa_users.handle"
    ORDER BY created DESC
    LIMIT 5

') or die(mysql_error());

while($row = mysql_fetch_array($query_post)) {
    echo $row['title'];
    echo '<span style="font-size:65%;font-style:italic">'.$row['created'].'</span>';
    echo '<br/>';
}

See this image for table structure
Table Strucute

  • 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-06-11T21:59:19+00:00Added an answer on June 11, 2026 at 9:59 pm

    The given error cames out when you do have same name column in both table…So you have to specify column name along with table name like in following patter:

    table_name.column_name
    

    So, your query should be like this:

    SELECT *
    FROM qa_posts, qa_users
    WHERE qa_posts.userid = "qa_users.handle"
    ORDER BY qa_posts.created DESC (or put the ORDER BY qa_users.created DESC if you want to make order by `created` of `qa_users` )
    LIMIT 5
    

    If you really not desired to have userid of value “qa_users.handle”, you should not quote them and should have query like this:

        SELECT *
        FROM qa_posts, qa_users
        WHERE qa_posts.userid = qa_users.userid AND qa_posts.type="Q" 
        ORDER BY qa_posts.created DESC 
        LIMIT 5
    

    You would better to use JOIN in following way:

        SELECT *
        FROM qa_posts INNER JOIN qa_users ON qa_posts.userid = qa_users.userid 
        WHERE qa_posts.type="Q" 
        ORDER BY qa_posts.created DESC 
        LIMIT 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I want to use multiple windows in my code, I normally do it
I want use this 1 for using Bar code or QR code scanner. I
I want to use a table valued function and call it from within multiple
I have a table with multiple rows, and I'm trying to use an xpath
I want to use multiple private keys to connect to different servers or different
I want to use multiple calendars and lose the time axis in the agenda
I want to use a single Doctrine install on our server and serve multiple
I want to use devise's tokens to support logging in/out in multiple clients at
I have WinForms app and multiple forms and want to use ErrorProvider component on
I want to load multiple languages to use IVONA SDK with SSML for iPhone.

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.