By using SELECT you can write the query this way:
SELECT @ModelID = m.modelid
FROM MODELS m
WHERE m.areaid = 'South Coast'
Are you interested in learning SQL from the basics! Refer to this video on SQL provided by Intellipaat:
By using SET you can write the query like this:
SET @ModelID = (SELECT m.modelid
FROM MODELS m
WHERE m.areaid = 'South Coast')
Note: Don’t use the select statement if it returns multiple values.
When you use SELECT, the last value gets assigned to the variable and that will be returned without any warning or error.