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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:11:52+00:00 2026-05-14T20:11:52+00:00

I want to insert 3 rows at a time in a table based on

  • 0

I want to insert 3 rows at a time in a table based on select statement..

consider the query

insert into tblTemp 
(
a,b
)

select a, b from tblTemp2

This lets me insert one row in tblTemp..

my requirement is to add 3 rows with iterative values a,a+1,a+2 for each b inserted.

  • 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-14T20:11:52+00:00Added an answer on May 14, 2026 at 8:11 pm

    Use a cross join to generate extra rows (via Cartesian product), rather than querying tblTemp2 three times with UNION ALL

    insert into tblTemp (a, b)
    select a + offset, b
    from
      tblTemp2
      cross join
      (SELECT 0 AS offset UNION ALL SELECT 1 UNION ALL SELECT 2) foo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is a table locked every time I insert something in it? Because I want
I have a HTML table which I add items to from javascript on an
I am having a difficult time forming a conditional INSERT I have x_table with
I am creating a stored procedure that produces reports based on data in a
I have a process that imports a lot of data (950k rows) using inserts
Imagine the following problem: You have a database containing about 20,000 texts in a
I am using and working on software which uses MySQL as a backend engine
I'm building a system which has the potential to require support for 500+ concurrent
I am interested in tracking my users' pageviews on my site. Being that traffic

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.