<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9 - Discussions by balexandre</title>
	<atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/balexandre/Discussions/RSS"></atom:link>
	<image>
		<url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
		<title>Channel 9 - Discussions by balexandre</title>
		<link>http://channel9.msdn.com/Niners/balexandre/Discussions</link>
	</image>
	<description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
	<link>http://channel9.msdn.com/Niners/balexandre/Discussions</link>
	<language>en</language>
	<pubDate>Wed, 19 Jun 2013 01:02:08 GMT</pubDate>
	<lastBuildDate>Wed, 19 Jun 2013 01:02:08 GMT</lastBuildDate>
	<generator>Rev9</generator>
	<c9:totalResults>0</c9:totalResults>
	<c9:pageCount>0</c9:pageCount>
	<c9:pageSize>0</c9:pageSize>
	<item>
		<title>Tech Off - SQL View question</title>
		<description><![CDATA[<p>It's easy <img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /><br>
<br>
SELECT c.ContactID, c.ContactName, d1.DepartmentName as MainDepartmentName, d2.DepartmentName as SecondDepartmentName
<br>
FROM contacts c<br>
INNER JOIN departments d1 ON d1.DepartmentID = <em></em>c.MainDepartment <br>
INNER JOIN departments d2 ON d2.DepartmentID = c.SecondDepartment <em><br>
<br>
<br>
<img src='http://ecn.channel9.msdn.com/o9/content/images/emoticons/emotion-1.gif' alt='Smiley' /> just use the alias and you can SELECT the same table as many times you need, just give it a diferent name (I'm using letters, but you can use all words, like departm01 or contacts, just with letters the code it's much simple to read)<br>
<br>
Bruno Alexandre<br>
&quot;a Portuguese in København&quot;<br>
<br>
Posted by sbc // Thu, Apr 6, 2006 7:49 AM</em><br>
<br>
Say I have a table of departments:<br>
<br>
departments<br>
-----------<br>
DepartmentID&nbsp;&nbsp;&nbsp; DepartmentName<br>
------------------------------<br>
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Department 1<br>
2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Department 2<br>
<br>
And a table as follows:<br>
<br>
<pre>contacts<br>--------</pre>
<pre>ContactID&nbsp;&nbsp; ContactName&nbsp;&nbsp;&nbsp;&nbsp; MainDepartment&nbsp;&nbsp; SecondDepartment<br>-------------------------------------------------------------<br>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fred Bloggs&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2<br>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bob Smith&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2</pre>
<br>
How would I create a view with the names for both MainDepartment and SecondDepartment?<br>
<br>
<pre>contactview<br>-----------</pre>
<pre>ContactID&nbsp;&nbsp; ContactName&nbsp;&nbsp;   MainDepartmentName&nbsp;&nbsp; SecondDepartmentName<br>-------------------------------------------------------------------<br>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fred Bloggs&nbsp;&nbsp;&nbsp;&nbsp; Department 1&nbsp;&nbsp;&nbsp;&nbsp;     Department 2<br>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Bob Smith&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Department 2&nbsp;&nbsp;&nbsp;&nbsp;     Department 2
<br></pre>
<br>
I tried CROSS JOIN but that did not work (1 entry&nbsp; in contacts resulted in one row in the view, but 2 entries resulted in 8)<br></p>]]></description>
		<link>http://channel9.msdn.com/Forums/TechOff/175406-SQL-View-question/e433b77cf92f40bfa13f9dea013b4434#e433b77cf92f40bfa13f9dea013b4434</link>
		<pubDate>Thu, 06 Apr 2006 07:24:32 GMT</pubDate>
		<guid isPermaLink="false">http://channel9.msdn.com/Forums/TechOff/175406-SQL-View-question/e433b77cf92f40bfa13f9dea013b4434#e433b77cf92f40bfa13f9dea013b4434</guid>
		<dc:creator>balexandre</dc:creator>
		<slash:comments>4</slash:comments>
		<wfw:commentRss>http://channel9.msdn.com/Niners/balexandre/Discussions/RSS</wfw:commentRss>
	</item>
</channel>
</rss>