I want to say:
SELECT tableA.stuff,tableB.morestuff,tableC.stillmorestuf f
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 3 1498
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.teranew s.com... I want to say:
SELECT tableA.stuff,tableB.morestuff,tableC.stillmorestuf f 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
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;
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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...
|
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...
|
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...
|
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...
|
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...
| |
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))....
|
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...
|
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...
|
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...
|
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,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |