现在我正在思考
USE [database]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[sp_Users_SelectAllByaccountRole]
(
@role int
)
AS
BEGIN
select * from Users
where (role = @role from Accounts)
&&
(Users.accountid == account.accountid)
END
但我不知道语法,我不确定我的逻辑,我们将非常感谢任何帮助。
答案 0 :(得分:1)
假设Role
列位于Accounts
表格上,那么它似乎只是一个简单的INNER JOIN
...
SELECT u.*
FROM Users u
INNER JOIN Accounts a on a.AccountID = u.AccountID
WHERE a.Role = @role