INSERT INTO [users]
(business_id, id)
FROM
(
SELECT
ID - (SELECT MIN(ID) FROM [users] WHERE business_ID = B.ID) AS business_id
,(SELECT MAX(ID)+1 FROM [users] WHERE business_ID = B.ID) AS ID
FROM [businesses] B
)
यदि आप इसे अपने द्वारा जोड़ी जा रही नई प्रविष्टियों से जोड़ते हैं, तो इसे समग्र कुंजी प्रदान करनी चाहिए
नया अपडेट:
INSERT INTO [users]
(business_id, id, name)
VALUES
(
3
,ISNULL((SELECT MAX(ID)+1 FROM [users] WHERE business_ID = 3),1) AS ID
,'d'
)