query in sql server for retrieving rows
- by Arash khangaldi
I have a table that contains the following 4 columns:
id
name
lastname
phone
I want to write a stored procedure that gets an id as parameter, and then gets the name of that id and then use that name to get all the rows that their name is equal to the names that i found in last step!
here it is my query, i know it's wrong but i'm new to sql commands:
ALTER PROCEDURE dbo.GetAllNames
@id int
AS
    select name as Name from Users where id = @id
    -- i don't how to retrieve the names that are equal to Name
select * from Users where name = Name 
can you correct my query and help me? Thanks.