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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:05:55+00:00 2026-05-29T11:05:55+00:00

i want to create a temporary table on the fly from a result set

  • 0

i want to create a temporary table on the fly from a result set so that i can run some queries against this resultset.

Here is my sql:

CREATE TABLE temp_table_1 AS (SELECT * FROM A LEFT OUTER JOIN B ON A.id = B.id WHERE B.id IS null);


SELECT QUA.id, QUA.name, QUA.address, QUA.acc, QUA.module, QUA.tag
FROM QUA,temp_table_1
WHERE 
QUA.name = temp_table_1.name AND 
QUA.acc = temp_table_1.acc AND
QUA.tag = temp_table_1.tag

When i run the first query to create the temp table, I get the error message:

‘Duplicate Colum Name ‘id”

Thanks a lot for your help.

  • 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-29T11:05:56+00:00Added an answer on May 29, 2026 at 11:05 am

    You’re getting both columns A.id and B.id without aliases to differentiate them. Be specific about the columns you select:

    CREATE TABLE temp_table_1 AS (
      SELECT 
        A.id AS aid
        A.othercol AS a_othercol,
        B.id AS bid,
        B.othercol AS b_othercol
      FROM A LEFT OUTER JOIN B ON A.id = B.id WHERE B.id IS null);
    

    It’s unwise to use SELECT * because you can’t always guarantee the order that the columns will return in, if something changed in the original CREATE TABLE statement, for example. Also, as you’ve discovered here, similarly named columns will cause problems in many circumstances.

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

Sidebar

Related Questions

want to create a temporary table that has an auto_increment field plus a field
I want to create a table variable or temporary table, using data from another
I want to create a simple http proxy server that does some very basic
We have a statement., that is inserting some rows in a temporary table (say
If i have this table on dataBase.js file: client.query( 'CREATE TEMPORARY TABLE IF NOT
I have created a temporary table using cakephp $this->Model->query() and inserted some records using
I'm using a stored procedure to create a temporary table and want to return
I want to insert a range of values into my table create TEMPORARY TABLE
Ok I have a temporary MySQL table with 135,000 rows, from this temporary table
I want to create a function which returns a temporary table of dates, for

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.