我有2张桌子,一张有候选人,另一张有工作机会。
候选人:
CandidateID
First Name
Last Name
Email
Address
City
State
招聘信息:
JobID
CompanyName
Address
City
State
我必须运行哪些查询才能获得与作业状态具有相同状态的所有候选项?
还有什么是将数据字段从网站连接到数据库的最佳选择?我应该使用什么样的数据库,除了MySQL?
答案 0 :(得分:0)
要进一步解释我的上述评论,您可以创建一个存储过程来传递状态参数,如下所示:
CREATE PROCEDURE dbo.GetCandidatesByState
@state varchar(2)
AS
SET NOCOUNT ON
BEGIN
SELECT c.*
,j.companyname
FROM Candidates AS C
INNER JOIN Job AS J ON c.desiredjobstate = j.[STATE]
WHERE c.desiredjobstate = @state;
END
或者,只需声明一个变量@state并传递一个如下所示的值:
DECLARE @state VARCHAR(2);
SET @state = 'NY';
BEGIN
SELECT c.*
,j.companyname
FROM Candidates AS C
INNER JOIN Job AS J ON c.desiredjobstate = j.[STATE]
WHERE c.desiredjobstate = @state;
END