I’m trying to do
SELECT * FROM a, b
However, it doesn’t return anything if one of the tables is empty. How do I make it so it returns ‘a’ even if the other one is empty?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using two tables in the
fromclause is functionally equivalent to across join:This returns a row of A for every row in B. When B is empty, the result is empty too. You can fix that by using a
left join. With aleft join, you can return rows even if one of the tables is empty. For example:As the condition
1=1is always true, this is just like across joinexcept it also works for empty tables.