Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Write a Query with a Right Outer Join
How To Write a Query with a Right Outer Join? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries
✍: FYIcenter.com
If you want to query from two tables with a right outer join, you can use the RIGHT OUTER JOIN ... ON clause in the FROM clause. The following query returns output with a right outer join from two tables: fyi_links and fyi_rates. The join condition is that the id in the fyi_links table equals to the id in the fyi_rates table:
mysql> SELECT l.id, l.url, r.comment FROM fyi_links l RIGHT OUTER JOIN fyi_rates r ON l.id = r.id; +------+-------------------+-----------+ | id | url | comment | +------+-------------------+-----------+ | 101 | dev.fyicenter.com | The best | | 102 | dba.fyicenter.com | Well done | | 103 | sqa.fyicenter.com | Thumbs up | | NULL | NULL | Number 1 | | NULL | NULL | Not bad | | NULL | NULL | Good job | | NULL | NULL | Nice tool | +------+-------------------+-----------+ 7 rows in set (0.00 sec)
Note that a right outer join may return extra rows from the second (right) table that do not satisfy the join condition. In those extra rows, columns from the first (left) table will be given null values.
The extra rows returned from the right outer join in this example represents rates that have no links.
2007-05-11, 4789👍, 0💬
Popular Posts:
How can you enable automatic paging in DataGrid ? Following are the points to be done in order to en...
What is difference between custom JSP tags and JavaBeans? Custom JSP tag is a tag you defined. You d...
What is the main difference between a Vector and an ArrayList? Java Vector class is internally synch...
How do I force the Dispose method to be called automatically, as clients can forget to call Dispose ...
What is the difference between CALL_FORM, NEW_FORM and OPEN_FORM? CALL_FORM: start a new form and pa...