Suppose we have 2 tables, Customer and Address, with the following fields each:
Customer
========
Id: INT
Name: VARCHAR(25)
Address_Id: INT (FK from Address Table)
Address
=======
Id: INT
Country: VARCHAR(25)
City: VARCHAR(25)
Street: VARCHAR(25)
StreetNumber: INT
Suppose I want to receive the address and user details of a user with Id: 15. Should I use a subquery that minimizes the cartesian product, like this:
SELECT *
FROM
(
SELECT Id
FROM User
WHERE Id = 15
) as u,
Address a
WHERE a.Id = u.Address_Id;
or should I just use the following obvious query?
SELECT *
FROM User u, Address a
WHERE u.Id = 15 AND u.Address_Id = a.Id;