How do I return values from a MySQL stored procedure?

I started learning MySQL after 20 years of working with SQL Server. 95% of my database queries are stored procedure calls, which I know a little more than everything about in SQL Server. 20 years of practice and successful implementation of many projects on SQL Server have convinced me that there are still more advantages than disadvantages in using stored procedures.

However, many constructs in MySQL seem to me not very convenient and not practical. Of course, this is my subjective perception. Except also, I've only been learning MySQL syntax for a couple of weeks, so please don't criticize me for the remark above. The comparison was forced and biased.

My question is that I can't find in MySQL an analog of a very convenient code in Transact-SQL:

create procedure my_stored_proc
  @p1 varchar(15),
  @p2 char10
as

set nocount on

declare @id int

select @id = some_id from some_table
where (some_val1 = @p1) or (some_val2 = @p2)
--я точно знаю, что после запроса выше @id будет инициализирован

select @id as 'Identifier'
--значение @id просто возьмёт и вернётся в вызывающий код

Please note that I declare a variable in the body of the procedure, then initialize it and want to return its value under the alias.

How do I implement this on MySQL? I've tried everything I found it on the Internet-I played with the parameters (in/out/inout), clearly substituted the values, and so on. But the stored procedure always returns NULL.

UPDATE

As is usually the case, I figured it out on my own only after I clearly formalized the problem in the form of a question. Here is my solution:

set @id = 0;

select @id = some_id from some_table
where (some_val1 = @p1) or (some_val2 = @p2)

select @id as 'Identifier';

So declare isn't for declaring a local variable at all, is it? I just take a variable (without an explicit declaration) and initialize it with zero, timidly hoping that MySQL will understand that the variable will be of type int. Question: and if I need bigint? How does MySQL decide what type of variable to initialize?

Well, with the return of the value, too, everything is clear. The syntax is no different from Transact-SQL.

I would appreciate more elegant solutions (if there are any).

Author: Interface Unknown, 2020-11-02