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.
Don’t “foreach loop” over SQL data – use the data as sets. So in your case – do it this way:
Nice, fast, set-oriented….