Reputation: 80
I want to select a value from differente tables, I have 2 tables that are users
and billing
, and I want to select the billings of @identifier
(variable) and then select the name of the sender of the bill.
I want to "join" two selects like:
SELECT *
FROM billing
WHERE identifier = @identifier
(@indentifier
is a local variable) and, at the same time:
SELECT *
FROM users
WHERE identifier = billing.sender
Upvotes: 1
Views: 58
Reputation: 1219
I think what you're looking for is a JOIN
. For example:
SELECT *
FROM billing b
JOIN users u ON u.identifier = billing.sender
WHERE b.identifier = @identifier
Upvotes: 1