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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:54:22+00:00 2026-05-27T20:54:22+00:00

I want to insert a range of values into my table create TEMPORARY TABLE

  • 0

I want to insert a range of values into my table

create TEMPORARY TABLE IF NOT EXISTS currency_numbers(
    num INT
);
insert into currency_numbers(num) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);

insert into pm_transaction_type (tran_type, fixed, rate, min_by_rate, max_by_rate, round, min_amount, max_amount, country_code, valid_since, valid_till, currency)
        select 'fee.transfer_other_free', null, 0.1, 0, null, 0, null, null, "", null, null, currency_numbers.num
        from currency_numbers
        union
        select 'fee.transfer_tip_free', null, 0.3, 4, null, 5, null, null, "", null, null, currency_numbers.num
        from currency_numbers;

In this example, I am using the union on 2 select statements, but I want to use union with about 10. Unfortunately, I am getting the following error:

Can't reopen table: 'currency_numbers'

How can I write this query, hopefully without having to repeat either the numbers of the list of attributes names each time?

  • 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-27T20:54:23+00:00Added an answer on May 27, 2026 at 8:54 pm

    That is a temporary table problem – You cannot refer to a TEMPORARY table more than once in the same query.

    TEMPORARY Table Problems

    As a workaround, try this one –

    SELECT t.*, c.* FROM currency_numbers c, (
      SELECT 'fee.transfer_other_free' tran_type, null fixed, 0.1 rate, 0 min_by_rate, null max_by_rate, 0 round, null min_amount, null max_amount, '' country_code, null valid_since, null valid_till
        UNION
      SELECT 'fee.transfer_tip_free', null, 0.3, 4, null, 5, null, null, '', null, null
      ) t;
    

    …and its INSERT version –

    INSERT INTO pm_transaction_type (tran_type, fixed, rate, min_by_rate, max_by_rate, round, min_amount, max_amount, country_code, valid_since, valid_till, currency)
      SELECT t.*, c.* FROM currency_numbers c, (
        SELECT 'fee.transfer_other_free' tran_type, null fixed, 0.1 rate, 0 min_by_rate, null max_by_rate, 0 round, null min_amount, null max_amount, '' country_code, null valid_since, null valid_till
          UNION
        SELECT 'fee.transfer_tip_free', null, 0.3, 4, null, 5, null, null, '', null, null
        ) t;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert say 50,000 records into sql server database 2000 at a
I want to insert something into a STL list in C++, but I only
I want to insert a new row into an Access database. I'm looking at
I want to insert multiple invisible watermarks into my JPEG pictures through C# code.
I want to insert a pair< string, vector<float> > into a map, first it
I want to insert a row into the Database using SqlDataAdapter. I've 2 tables
I have a situation similar to the following question: Insert Data Into SQL Table
Just want to insert a word or text at the beginning of range of
I am using generate_series to insert values in a table. And generate_series insert values
I want to insert a group box in the form and put in 3

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.