Hi Everyone,
I am new to SQL Server, but have played around with MS Access a fair bit.
I am currently trying to create an Outer Right Join on a Table and Query in SQL Server. Heres query from Access Query builder below: - SELECT tblPhone.custID, NotMobile.CustMoreThanMob
-
FROM NotMobile RIGHT JOIN tblPhone ON NotMobile.CustMoreThanMob = tblPhone.c_uid
-
WHERE (((NotMobile.CustMoreThanMob) Is Null));
Notes:
1. tblPhone is a Table and it contains the field CustID
2. NotMobile is a Query and it contains the field CustMoreThanMob
2.Heres the query that defines "NotMobile" in the above query: - SELECT Left([PhoneNumber],3) AS Type, tblPhone.custID AS CustMoreThanMob
-
FROM tblPhone
-
GROUP BY Left([PhoneNumber],3), tblPhone.custID
-
HAVING (((Left([PhoneNumber],3))<>614));
I have tried to get the top query to run in SQL Server in the following ways:
1. - SELECT custID, CustMoreThanMob
-
FROM NotMobile OUTER RIGHT JOIN tblPhone ON NotMobile.CustMoreThanMob = tblPhone.c_uid
-
WHERE CustMoreThanMob Is Null;
* Please note that all instances of the query "NotMobile" have been replaced by the words "NotMobile" . In the actaul query I have put the whole SQL String in round brackets.
Thank You in Advance
2 3533 gpl 152
New Member
I dont have SQL Server with me, so I cannot verify the code
Basically, your sub query needs to be set up as a derived table so that it can be joined.
Many years ago I read an article that said SQL Server is optimised for Left (as opposed to Right) outer joins, so have re-written it that way.
This should get you started - SELECT tblPhone.custID, NotMobile.CustMoreThanMob
-
FROM tblPhone left outer join
-
(
-
SELECT Left([PhoneNumber],3) AS Type, tblPhone.custID AS CustMoreThanMob
-
FROM tblPhone
-
GROUP BY Left([PhoneNumber],3), tblPhone.custID
-
HAVING (((Left([PhoneNumber],3))<>614))
-
) NotMobile
-
-
ON NotMobile.CustMoreThanMob = tblPhone.c_uid
-
WHERE (((NotMobile.CustMoreThanMob) Is Null))
NeoPa 32,568
Recognized Expert Moderator MVP
You don't seem to say what your actual problem is, but in case it helps, the RIGHT OUTER JOIN is a type of outer join qualified by RIGHT. Not a type of right join qualified by OUTER.
MSSQL can be very forgiving, so I can't say what you've used will necessarily fail (and I have no info from you on the matter) but I wouldn't expect that to work.
In Jet SQL (used by Access) that you're more used to there is only support for the LEFT & RIGHT OUTER JOINs (just called LEFT JOIN & RIGHT JOIN generally) but MSSQL also supports the third type (FULL) of OUTER JOINs. SQL JOINs may be of some help.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Joerg Ammann |
last post by:
hi,
os: aix 4.3.3
DB2: version 7 FP3
we are using a federated DB setup, datasource and fed-Db are both
V7FP3 (in fact they are on the same server) and are having massiv
performance problems.
i tracked it back to the way the queries are push-downed to the
|
by: Beowulf |
last post by:
The problem:
I'm updating a report to be "multi-language" capable. Previously,
any items that had text associated with them were unconditionally
pulling in the English text. The database has always been capable of
storing multiple languages for an item, however.
Desired output:
Given the test data below, I'd like to get the following results
select * from mytestfunc(1)
|
by: BigGuy316 |
last post by:
strSQL = "SELECT tblf107grpDept.DeptName AS Org, tblUsers.UserFName + ' ' + tblUsers.UserLName AS Requestor,CONVERT(varchar,
tblF107Log.RecDate) + ' EST' AS , tblF107Log.Comments AS Comments, tblF107Log.IDFrm FROM dbo_tblF107grpDept
RIGHT JOIN tblUsers ON tblF107grpDept.IDDept = tblUsers.IDDeptfk RIGHT JOIN tblF107Log ON tblUsers.UserID =
tblF107Log.IDContact WHERE IDFrm = " & request.querystring("IDForm") & ";"
Set rsCoordinationSection...
|
by: Viendra |
last post by:
I am attempting to determine which of the following Program Cods(A) below are ]not contained within the Program Tranlation Code Table (B) using the follwing SQL query:
SELECT DISTINCT .
FROM Program_Translation RIGHT JOIN ON Program_Translation.ID = .ID
WHERE (((.)<>"CC-P"));
The output of the query is listed below (C).
I used basically the same query for determining Product Lines(A1) not contained within an productline tranlation...
|
by: MP |
last post by:
Hi
trying to begin to learn database using vb6, ado/adox, mdb format, sql
(not using access...just mdb format via ado)
i need to group the values of multiple fields
- get their possible variations(combination of fields),
- then act on each group in some way ...eg ProcessRs (oRs as RecordSet)...
the following query will get me the distinct groups
| |
by: cihpet |
last post by:
Hallo,
I am beginner,
I want to show on page results of this query: $query="SELECT mr_prehlad.mr_id, mr_kontakt.nazov_mr FROM mr_prehlad RIGHT JOIN mr_kontakt ON mr_kontakt.id_mr=mr_prehlad.mr_id WHERE mr_prehlad.'$co'='1' ORDER BY mr_prehlad.mr_id ";
But this while ( $row = MySQL_Fetch_Field( $result ) ) {
echo "<tr>\n";
foreach( $row as $hodnota ) {
echo "<td>\n";
echo $hodnota;
echo "</td>\n";
|
by: qarmoe |
last post by:
Please open the Screen Print (attached), else it's not gonna makes
sense...
http://download.yousendit.com/A61005CA7194C418
SELECT DISTINCT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Name) Not Like "msys*" And (MSysObjects.Name) Not
Like "all*") AND ((MSysObjects.Type)=1));
|
by: qarmoe |
last post by:
Is there a vb that can create right join from a static table
to
all the table names resulting from the query below ? SSID is the
common fields in all the
tables.
This query gives all the temp tables
SELECT DISTINCT MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Name) Not Like "msys*" And & _
|
by: rouch |
last post by:
After a month of troubleshooting, I am at a loss, and hope some good soul here can help. I have three tables UCC, Acknowledgement, BSD. I need to create a record in the BSD table, have accounts in the UCC table review the BSD record, and acknowlege the record. After they acknowledge it, I want a line item to be created in the Acknowledgement table. I need accounts in the UCC table to view only the BSD's they have acknowledged and the BSD's...
|
by: Giorgio |
last post by:
Hi,
I have a table with a date_created and date_expired and I want to look
at the 15th of each month and every month since the system started and
count up how many accounts were active at each of those points in
time.
Will have to assume that if there's an expiry date bigger than today
then that account was active at each of those points in time.
I created a numbers table from 1 to 100.
I have the following code working well in...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |