Link to home
Create AccountLog in
Avatar of MikeMCSD
MikeMCSDFlag for United States of America

asked on

Query problem

I want to return these fields:    UserID, PW, IsMember, FName

But, If "IsMember" is True, I want the UserID field from the Users table
to be replaced with the MemID from the Member table.
(Of course if the @Email doesn't exist I just want to return).  Thanks

CREATE PROCEDURE GetMemberPW
(@Email varchar(90))
AS

SELECT UserID, PW, IsMember, FName
FROM Users
WHERE Email = @Email

IF IsMember = 1

 SELECT MemID
 FROM Member
 WHERE UserID = @UserID
SOLUTION
Avatar of Lowfatspread
Lowfatspread
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of MikeMCSD

ASKER

Thanks guys. . .
Lowfat, I got an error: Ambiguous column name 'UserID'.
aneeshattingal's worked.