Tom Knowlton
asked on
select values into an "insert"
I want to take these values and insert them into another table:
The menuids are not guaranteed to be 531 and 532, so I need to use the select to find-out what they are by finding the values of other columns on the same row.
But I don't want to just insert the menuids, I want to insert other values as well that do not come from a table but will be hard-coded.
Not sure how to do this.
the resulting action would be essentially doing this:
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<first menu id from the select>>, 0, 0, 3, 1)
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<first menu id from the select>>, 0, 0, 4, 1)
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<second menu id from the select>>, 0, 0, 3, 1)
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<second menu id from the select>>, 0, 0, 4, 1)
So there will be 2 sets of inserts for each menu id returned from the select I described.
The menuids are not guaranteed to be 531 and 532, so I need to use the select to find-out what they are by finding the values of other columns on the same row.
But I don't want to just insert the menuids, I want to insert other values as well that do not come from a table but will be hard-coded.
Not sure how to do this.
the resulting action would be essentially doing this:
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<first menu id from the select>>, 0, 0, 3, 1)
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<first menu id from the select>>, 0, 0, 4, 1)
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<second menu id from the select>>, 0, 0, 3, 1)
insert into menuperm (menuid, clientid, clientsid, roleid, setting)
values (<<second menu id from the select>>, 0, 0, 4, 1)
So there will be 2 sets of inserts for each menu id returned from the select I described.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks!<br /><br />It's nice to have several options!
ScottPletchers version should be faster still as only 1 select from the Menu table is specified (though this would only be noticable if the table is very large)