存储过程返回最新的客户ID。
通过传递两个变量返回最新的客户ID。在这种情况下,一个变量是单元号,另一个是设施策略号。
再次感谢你们!
CREATE PROCEDURE [dbo].[Getcustomerinfo] (@UN VARCHAR(20),
@FPN VARCHAR(20))
AS `enter code here`
BEGIN
SELECT customers.id,
customers.full_name,
customers.address,
customers.city,
customers.state,
customers.zip_code,
customers.phone_number,
customers.email_address,
policys_transactions.unit_number
FROM customers
INNER JOIN policy_facility_customer
ON customers.id = policy_facility_customer.customer_id
INNER JOIN policys_transactions
ON policy_facility_customer.cert_number =
policys_transactions.cert_number
WHERE ( policys_transactions.unit_number = @UN
AND policys_transactions.facility_policy_number = @FPN )
ORDER BY customers.ID DESC
END