I am trying to create a stored procedure to accomplish 2 things. I've commented my code below to help you understand my logic.
/* @Promo='somechars' */ SELECT @Aid=AgentId /*assign the selected column value to @Aid */ FROM ATABLE /*from this table */ WHERE PromoNumber=@Promo /*where col PromoNumber='somechars' SELECT AName As AgentName, Office, Email FROM ANOTHERTABLE WHERE Id=@Aid /*Get all info for AgentID from first select*/ /*Then start from the first SELECT again to display the next AgentID that the WHERE specifies*/
However, my code will only ouput a single AgentId. There should be 4 AgentId's that meet the conditions of the WHERE clause in the first select statement.
Any Ideas? Thanks! I hope my explanation was good enough. I'm here so reply if you have any questions.