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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:49:59+00:00 2026-06-03T01:49:59+00:00

I have a table that is basically set up so there is an id(UNIQUE),mapID,employe_ID,

  • 0

I have a table that is basically set up so there is an id(UNIQUE),mapID,employe_ID, and a value… it looks sort of like this

Table

ID    mapID       employee_id     value
1       1         1               Brian
2       1         1               617-555-5555
3       1         2               Boston Office
4       1         2               Mary
5       3         1               617-666-6666
6       3         2               New york office

I want to loop thru this table so “for each” same employee_id, I can do an insert statement into another table where it is setup a little cleaner.

Like this will give you rough idea of what i am trying to convey.

Select * from table where employe_id=1
foreach(item in aboveSelect)
{
   Insert into table2
}

Obviously this is not the correct syntex.

  • 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-03T01:50:00+00:00Added an answer on June 3, 2026 at 1:50 am

    Don’t “foreach loop” over SQL data – use the data as sets. So in your case – do it this way:

    INSERT INTO dbo.Table2(Col1, Col2, ...., ColN)
      SELECT Col1, Col2, ...., ColN
      FROM dbo.table 
      WHERE employee_id=1
    

    Nice, fast, set-oriented….

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

Sidebar

Related Questions

I have a table that looks like this: id value AGA 0.211 AGA 0.433
I have a table that looks basically like this: id | redirectid | data
I have a table that looks like this: CREATE TABLE foobar ( id SERIAL
I have a table code_prices that looks something like this: CODE | DATE |
I have a table which looks like this (in html): <div id=product_grid_one> <table> <tr>
I'm seeing basically the same issue described here I have a table that starts
I have an application that shows data from a MySQL table. Basically, my application
Basically I have a database with two tables, that is, Updates table and Images
I have a MyISAM table that basically contains a log. A cluster of machines
I have a table containing hierarchical data. There are currently ~8 levels in this

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.