Solved

New to inner join

Posted on 2008-10-23
4
236 Views
Last Modified: 2010-04-14
What does ".." follow by table name means? mydbname..mytablname1 a
What is the alternative?


select a.test, b.test2
from mydbname..mytablname1 a  
inner join mydbname2..mytable2 b
on a.test = b.test2
where a.test = 'myvalue'
0
Comment
Question by:VBdotnet2005
4 Comments
 
LVL 7

Expert Comment

by:talker2004
ID: 22792825
The only time i have ever seen "..." together like that in sql server is when you are using linked servers.

Normally the ... is not required, but if you are linking an access database to your sql server you will need the ... in order to query the table.

It is also possible to link other databases to your sql server.

http://msdn.microsoft.com/en-us/library/ms188279.aspx


Did you have any other questions or issues with the query?

0
 
LVL 26

Assisted Solution

by:Anurag Thakur
Anurag Thakur earned 25 total points
ID: 22793241
DatabaseName..TableName syntax is normally used when you want to join 2 databases in a query (different kind of joins)
0
 
LVL 20

Accepted Solution

by:
informaniac earned 50 total points
ID: 22793308
.. is used for the username as dbo... if u have a username for the db then u write like this
mydbname.user1.mytablname1
0
 
LVL 10

Assisted Solution

by:jinn_hnnl
jinn_hnnl earned 50 total points
ID: 22794217
addition to those answers:

Normally if you want to join 2 table with foreign key constraints using inner join (which data has to exist in both parent and child table), and these 2 databases are in the same database. You dont have to specify the database name at the beginning. Just go:

(database: Organization)
Select U.*, C.CompanyName
From Companies C
INNER JOIN Users U
ON C.CompanyID = U.CompanyID

if this Users Table is in different database (Branches) then you have to specify:
Select U.*, C.CompanyName
From Companies C
 INNER JOIN Branches.dbo.Users U
 ON C.CompanyID = U.CompanyID
-- or : ON C.CompanyID = Branches.dbo.Users.CompanyID

when you run this query you are connecting to Orgranization database, that's why you only have to mention DB name for Users, but it safe to do both.

Hope this helps

JINN


 
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question