Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL question on a Join

Status
Not open for further replies.

jfield817

Programmer
Jun 2, 2000
153
US
Is this query valid ?<br><br>There r 3 tables, Table1,&nbsp;&nbsp;X,&nbsp;&nbsp;and Y<br>Y has a field c among others.<br><br><br>Insert into Table1 (a, b, c)<br>(Select X.a, X.b, X.c From X)<br>Join Y on X.c = Y.c<br><br>Thanks<br>John <br><br><br><br><br><br>
 
Almost -<br>INSERT INTO TABLE1<br>Select X.a, X.b, X.c <br>From X INNER JOIN Y on X.c = Y.c<br><br>Join usually means INNER join - I usually make it explicit because I enjoy typing.&nbsp;&nbsp;The parentheses you had will cause a syntax error. <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
As I understand it ...<br>Data from table X is loaded into Table1 ...<br><br>But doesnt the placement of the Inner Join <br>phrase mean that Table1 is part of the join ...<br><br>Could you explain what is happening ?<br>It is confusing<br><br>thanks<br>john<br>
 
From X INNER JOIN Y on X.c = Y.c means X is joined to Y only where X.c is equal to Y.c.<br>Table1 is not involved in the join at all, but merely has the result set of the query<br>&quot;Select X.a, X.b, X.c <br>From X INNER JOIN Y on X.c = Y.c&quot;<br>inserted into it.<br>I am assuming the result set matches the table structure of Table1.&nbsp;&nbsp;If not, then you have to be explicit about which fields in Table 1 are the lucky recipients of this data. <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top