473,889 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repost: Syntax - or unavailability of same - for variable join??? Can anyone help?

Ben
I want to say:

SELECT tableA.stuff,ta bleB.morestuff, tableC.stillmor estuff
FROM tableA,
LEFT OUTER JOIN tableB ON (AB match conditions)
LEFT OUTER JOIN tableC ON (AC match conditions)
WHERE etc

However, in some cases, tableB does not have rows where the other two do
(it contains credit card records... but when an order is paid by check, there is
no record.)

What happens with the above syntax is I don't get a row at all.

Is there a way to say that if tableB has no row, I get blank columns?

Maybe I'm just looking at the wrong, but I can't seem to find out how, or
if, one can do this.

Thanks for any input.

--Ben
Nov 22 '05 #1
3 1523
You might have better success with the form of HAVING and appropriate use of
OR IS NULL as opposed to strict JOIN and WHERE conditions...

Similar to...

SELECT A.a, B.b, C.c FROM A, B, C
HAVING (A.b = B.b OR B.b IS NULL)
GROUP BY A.b;

--
Greg Patnude / The Digital Demention
2916 East Upper Hayden Lake Road
Hayden Lake, ID 83835
(208) 762-0762

"Ben" <re***@to-the-newsgroup.com> wrote in message
news:4c******** *************** *******@news.te ranews.com...
I want to say:

SELECT tableA.stuff,ta bleB.morestuff, tableC.stillmor estuff
FROM tableA,
LEFT OUTER JOIN tableB ON (AB match conditions)
LEFT OUTER JOIN tableC ON (AC match conditions)
WHERE etc

However, in some cases, tableB does not have rows where the other two do
(it contains credit card records... but when an order is paid by check, there is no record.)

What happens with the above syntax is I don't get a row at all.

Is there a way to say that if tableB has no row, I get blank columns?

Maybe I'm just looking at the wrong, but I can't seem to find out how, or
if, one can do this.

Thanks for any input.

--Ben

Nov 22 '05 #2
Ben
I'll have a look at that; thank you very much for taking the time to reply. :)

Ben
On Mon, 16 Feb 2004 22:03:22 -0800, Greg Patnude wrote:
You might have better success with the form of HAVING and appropriate use of
OR IS NULL as opposed to strict JOIN and WHERE conditions...

Similar to...

SELECT A.a, B.b, C.c FROM A, B, C
HAVING (A.b = B.b OR B.b IS NULL)
GROUP BY A.b;


Nov 22 '05 #3
Ben
As it turns out, LEFT OUTER JOIN does exactly what I want.

I'm not sure what my original problem was now, though I suspect it was
part of the "where" clause depending on the right side of the join.

So for anyone who might find this thread in a search for this kind of
behaviour, just use LEFT OUTER JOIN. You get the left columns, plus the
right ones where there are records, and NULL for the right columns where
there are no records.

HAVING and GROUP BY have nothing to do with this behaviour, and will lead
you down a dead-end.

Ben
Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

699
34429
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
23
1878
by: middletree | last post by:
I've seen posts here and elsewhere which read something along the lines of "PULLNG MY HAIR OUT!!!!!" or "HELLLLPPP!". Well, I know that kind of subject line isn't descriptive, but I sure can relate right now. I've been struggling for days--days!!-- on this one simple query. I really need to get past this thing and move on. Please help. I have a classic ASP page, and it gives you 4 dropdowns. You can select any or none of them....
7
248507
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a particular surname in a particular town. I can select the records fine with this syntax (testing in Oracle SQL* Plus) SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME, NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
4
2867
by: Toonman | last post by:
I'm trying to use a couple of variables in a stored procedure. Things work fine when I hard code the data into the variables and also work fine when I use the variable in the WHERE clause and hard code data for the other variable. So, I think I have a syntax problem when trying to use "FrontPage.@FrontpageProduct" as seen in my example code below. I've tried many variations... and either get syntax errors or end up with a result of "no...
0
977
by: Ben | last post by:
I want to say: SELECT tableA.stuff,tableB.morestuff,tableC.stillmorestuff FROM tableA, LEFT OUTER JOIN tableB ON (AB match conditions) LEFT OUTER JOIN tableC ON (AC match conditions) WHERE etc However, in some cases, tableB does not have rows where the other two do (it contains credit card records... but when an order is paid by check, there is
2
1477
by: martinharvey via DotNetMonster.com | last post by:
I would be very grateful if someone could help me with a stored procedure syntax problem I want to insert the value "OrderTotal" into databasetable("Newtable") column "OrderTotal" (money (8)). The value can be returned from the page (Dim amount As Decimal = ShoppingCart.GetTotal() totalAmountLabel.Text = String.Format("{0:c}",amount) or returned by the function "ShoppingCart.GetTotal". This is the syntax i have tried, but I get the...
1
2360
by: iporter | last post by:
In the following code, the two Response.Write statements output exactly the same - I can copy and paste both into Query Analyzer, and run them fine. However, if I comment out line 3, the assignment of "SELECT T..." to the variable query, the last line produces the error: Line 1: Incorrect syntax near '<'. Many thanks in advance for any explanation - the problem is tearing my hair out!! Iain
2
1598
by: Tony K | last post by:
I'm slowly converting views from an SQL DB to Jet (Access) and I'm having some problems with the syntax. Can anyone tell me what the problem is with the syntax of the following SQL statements for Access? SELECT customer.customer_id, address.address1, address.address2, address.city, address.state, address.postal_code, address.country, address.record_status, customer.record_status AS Expr1, customer.company_id,...
2
2618
by: HalfCoded | last post by:
Hi everyone, I am currently working at learning perl but come up with two problems i can't clear on my own. I use perl version 5.8 on windows xp The complete I am working on is supposed to find motifs in a sequence. This is the complete code #!/usr/bin/perl -w use strict;
0
9962
marktang
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...
0
9810
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10791
jinu1996
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...
1
10889
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,...
0
9609
agi2029
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...
1
7993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5829
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...
0
6029
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4647
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.