473,503 Members | 1,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Who knows the answer?

Ron
I've got 3 tables

table1 containing the field A en field B en C
A en C always have a value, C sometimes
C only has to be checked against table 4 when it's not zero

table2 containing the field A as primary key
table3 containing the field B as primary key
table4 containing the field C as primary key

select from
table1
inner join table2
on table1.A = table2.A
inner join table3
on table1.B = table3.B
inner join table4
on table1.C = table4.C

this doesn't werk when C = zero
no row is returned then

how solve this problem?
So, check for C in table 4 when C has a value
don't check for C in table 4 when C = zero
--
Met vriendelijke groet
Ron van der Poel
fa*******@wanadoo.nl
Nov 12 '05 #1
1 1198
Your query will work if you replace the last INNER JOIN with a LEFT
OUTER JOIN.
select ....
from table1
inner join table2
on table1.A = table2.A
inner join table3
on table1.B = table3.B
left outer join table4
on table1.C = table4.C

The resulting row will have a null value for any column selected from
table4.

You say that you are "checking" the values in fields A,B,C. Why are you
doing this with an SQL statement? DM2 supports foreign keys which will
perform this check for you "automatically" during insert and update
processing of the table1 rows.

If column (field) C allows nulls and you use a null instead of a zero
value; then foreign keys will be able to perform all of the checking. In
this case; retrievals of column C should be coded as: VALUE(c,0) to
provide the zero value when the column contains a null.

If you have to store the zero value in column C; you can use foreign
keys for columns A and B and use a trigger to validate column C, when
not zero, when inserts or updates are done. This has the advantage of
keeping the table validation code out of the application program(s).

Philip Sherman

Ron wrote:
I've got 3 tables

table1 containing the field A en field B en C
A en C always have a value, C sometimes
C only has to be checked against table 4 when it's not zero

table2 containing the field A as primary key
table3 containing the field B as primary key
table4 containing the field C as primary key

select from
table1
inner join table2
on table1.A = table2.A
inner join table3
on table1.B = table3.B
inner join table4
on table1.C = table4.C

this doesn't werk when C = zero
no row is returned then

how solve this problem?
So, check for C in table 4 when C has a value
don't check for C in table 4 when C = zero
--
Met vriendelijke groet
Ron van der Poel
fa*******@wanadoo.nl


Nov 12 '05 #2

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

Similar topics

0
1688
by: Michael | last post by:
Hi, I am looking for a poll script with a special feature. Normally poll scripts display for every answer option ONE bar according to how many votes the answer got. I am looking for a script...
4
1990
by: N3TB1N | last post by:
Here is my assignment. I am hoping that someone here quickly knows all of the correct answers... especially for question #5 and everything after. Thanks in advance. ...
74
3942
by: Suyog_Linux | last post by:
I wish to know how the free()function knows how much memory to be freed as we only give pointer to allocated memory as an argument to free(). Does system use an internal variable to store allocated...
8
1158
by: Enrico Palazo | last post by:
I've asked on every forum that I can find, I'll try here. Why would "smartnavigation" work on some .net servers and not others. "smartnavigation is buggy", will not be accepted as an answer. ...
47
1906
by: Lauren Wilson | last post by:
One more try. After ransacking the Desktop AND Enterprise edition of Ken Getz Dev Handbooks on Access 2002, I STILL don't know if it is or is not possible to link a client side MDE with a WEB...
68
15622
by: James Dow Allen | last post by:
The gcc compiler treats malloc() specially! I have no particular question, but it might be fun to hear from anyone who knows about gcc's special behavior. Some may find this post interesting;...
2
3655
by: nivedita | last post by:
Hi All, I want to dot net interview question with answer if any one have question with answer please send me.. i am fresher Thanks in advance.. Nivedita
4
3160
by: David Wright | last post by:
Hello Folks I have a Macro which consecutively opens seven ‘Make Table Query’s’. Each query requests two parameter inputs i.e. ‘Please Enter Department Code’ and ‘Please Enter Year’. It is...
2
1495
by: Sapera | last post by:
I want to create an text field then a submit button. The text field is supposed to be the answer of a question. If the user types the correct answer and clicks submit, he is taken to the next...
0
7202
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,...
0
7084
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...
0
7278
Oralloy
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,...
0
7328
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...
1
6991
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...
0
7458
tracyyun
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...
0
5578
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,...
0
3167
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...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.