SQL Alias of joined tables?

Add the where clause to the subquery like this: select a1. Name, b1. Info from ( select name, id from table1 a where a.

Status = 1 ) as a1 right outer join ( select id, info from table2 be ) as b1 on (a1. Id=b1. Id).

SELECT a1. Name, b1. Info FROM table2 b1 JOIN table2 a1 ON b1.Id= a1.

Id AND a1. Status = 1 A right outer join does the exact same thing as a left outer join, with just the tables switched. You can filter on the join and it will still include the data from the initial table.

Select a1. Name, b1. Info from (select name, id, status from table1 a WHERE status=1) as a1 right outer join (select id, info from table2 b) as b1 on (a1.Id=b1.

Id) EDIT: For your second scenario: select a1. Name, b1.Info from (select name, id, status from table1 a) as a1 right outer join (select id, info from table2 b) as b1 on (a1. Id=b1.

Id) EXCEPT select a1.Name, b1. Info from (select name, id, status from table1 a WHERE status1) as a1 right outer join (select id, info from table2 b) as b1 on (a1. Id=b1.Id) That should work since you will get all the table2 data regardless.

EDIT 2: OK, to get everything from table2 EXCEPT where there is a status ID in table 1, even if there is not an entry in table1, you need to use the EXCEPT function, which will basically exclude a subset from a larger dataset.

See above. Since this is an outer join, this won't work. It won't actually exclude all the stuff being pulled from table2.

– Lincecum Nov 1 '10 at 18:39 Is there another reason you need to do a RIGHT OUTER JOIN on this instead of left or inner? In most cases a RIGHT JOIN is pretty much never called for. – JNK Nov 1 '10 at 18:43 Not really, as long as it's an outer join – Lincecum Nov 1 '10 at 18:49 Make it a LEFT OUTER JOIN and problem solved, unless you need orphan records from your table2.

– JNK Nov 1 '10 at 18:55 I did want all records from table2 initially, until I realized it doesn't really make sense in this scenario. Still, I feel like there might be a scenario where I would want to check constraints after performing an outer join, and I don't think any of the solutions solve that. Maybe that scenario just doesn't exist though.

– Lincecum Nov 1 '10 at 19:18.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions