user3250818
user3250818

Reputation: 247

Select columns from two different table with different fields in one query Access database

I have the table tbl_Discount with these columns:

And the table tbl_Tarrif with these columns:

I want to select Discount and Price in a single query and it's easy in SQL Server using a stored procedure but, in Access I don't know how to do it.

I tried this:

SELECT Discount
  FROM tbl_Discount
 WHERE (d_ID = ?)
 UNION
SELECT Price
  FROM tbl_Tariff
 WHERE (p_ID = ?)

But it returns two rows with one column each:

Discount
0
75000

And I want two columns (discount, price) on a single row, like this:

Discount Price
0        75000

Upvotes: 2

Views: 6446

Answers (1)

Farvardin
Farvardin

Reputation: 5414

try this :

SELECT Discount , Price
FROM tbl_Discount, tbl_Tariff
WHERE d_ID = ? AND p_ID = ?

Upvotes: 1

Related Questions