Solved

New to inner join

Posted on 2008-10-23
4
231 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now