I have two tables in a Database
: Menu and Companies. Both are connected by the CompanyID
. In the company
table there are nearly 100 rows of information on different companies. I can insert one row into the Menu table by this sql
query
:
INSERT INTO `menu` (`CompanyID`, `MenuName`, `MenuLink`, `ImageLink`,
`ListOrder`, `Popup`, `ParentMenuID`, `IsActive`, `IsAdmin`) VALUES
('11', 'Holidays', 'lookups/Holidays.aspx', 'images/Archive.png', '11',
'1', '1807', '1', '0');
I set the CompanyID
to 11 here. But I don't want to do an insert query
for each CompanyID so if there a way to insert for all the companies?
INSERT INTO menu (CompanyID
, MenuName
, MenuLink
, ImageLink
, ListOrder
, Popup
, ParentMenuID
, IsActive
, IsAdmin)
SELECT CompanyID
, 'Holidays'
, 'lookups/Holidays.aspx'
, 'images/Archive.png'
, '11'
, '1'
, '1807'
, '1'
, '0'
FROM companies
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments