在下面的存储过程中,我想要返回DEL
列中没有Flag
的行。当我得到结果时,包含DEL
行。我在WHERE
条款中做错了什么(我假设它是什么)?
ALTER PROCEDURE [dbo].[GetAllMessages]
-- Add the parameters for the stored procedure here
@Key varchar(30)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT message.msg_id,
message.tenant_id,
message.sender_id,
message.recipient_id,
message.recipient_email,
message.description,
message.date_recorded,
message.filename,
message.size_bytes,
message.size_time,
message.filepath,
message.Flag,
message.title,
message.date_activity,
member.member_image_url
FROM message
INNER JOIN member
ON message.sender_id = member.person_id
WHERE sender_id = (SELECT person_id FROM auth_key WHERE key = @Key)
OR recipient_id = (SELECT person_id FROM auth_key WHERE key = @Key)
AND Flag != 'DEL'
END
答案 0 :(得分:0)
我怀疑你需要一些额外的功能来按照你想要的方式对逻辑进行分段:
WHERE (sender_id = (SELECT person_id FROM auth_key WHERE key = @Key)
OR recipient_id = (SELECT person_id FROM auth_key WHERE key = @Key))
AND Flag != 'DEL'