Donutsrool
Donutsrool

Reputation: 80

Select from different tables -> users and billing

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

Answers (1)

silleknarf
silleknarf

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

Related Questions