dbTalk Databases Forums  

Cross Join give value on where it's should be NULL

comp.databases comp.databases


Discuss Cross Join give value on where it's should be NULL in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lemune
 
Posts: n/a

Default Cross Join give value on where it's should be NULL - 09-03-2007 , 05:16 AM






Hi again.

My problem now is when I use Cross Join on the record where it should
be null value it give another value.

First I give try without cross join, this is my query :

Code:
SELECT P.name, M.date, M.type, D.invoice_id, D.amount FROM payment_methods AS P INNER JOIN payment_receives AS M ON M.payment_method_id=P.payment_method_id AND M.date BETWEEN CAST( '2007-09-03 00:00:00' AS Datetime ) AND CAST( '2007-09-03 23:59:59' AS Datetime ) Inner JOIN payment_receive_details AS D ON M.payment_receive_id=D.payment_receive_id;

It give me 5 record.

I want to make a report base on this data, but my report is on
crosstab report, where there are 3 kind of payment method group.

So I Use this query:

Code:
SELECT G.name,M.payment_receive_id,P.name, M.date, M.type, D.invoice_id, D.amount FROM payment_method_groups As G Cross Join payment_methods AS P Inner JOIN payment_receives AS M ON M.payment_method_id=P.payment_method_id Inner JOIN payment_receive_details AS D ON M.payment_receive_id=D.payment_receive_id Where M.date BETWEEN CAST( '2007-09-03 00:00:00' AS Datetime ) AND CAST( '2007-09-03 23:59:59' AS Datetime );

It give me 15 record, but each D.amount value of the empty record has
a value same as the value of the existing record.
My purpose is to create Empty value (Null).

Where do i make an error?

Help please.

Thank you.


Reply With Quote
  #2  
Old   
--CELKO--
 
Posts: n/a

Default Re: Cross Join give value on where it's should be NULL - 09-03-2007 , 10:44 PM






Why are payment methods in a table? They are an ATTRIBUTE of a
payment, aren't they? Therefore is also no such data element as a
"payment_method_id" because a payment method cannot be an entity.

If you had posted DDL, we could try to fix your real and serious
design problems. DATE is reserved word and too vague to use as a
data element name. Likewise, name of what? type of what? Blood?
amount of what? all too vague and useless.

You might able to kludge up a query with an OUTER JOIN, but who knows
without DDL? Post the DDL and we can try again; try usig proper
ISO-11179 names and being consistent in uppercasing reserved words, so
we can red you code, too.




Reply With Quote
  #3  
Old   
Lemune
 
Posts: n/a

Default Re: Cross Join give value on where it's should be NULL - 09-05-2007 , 03:38 AM



I have solved the problem.
I will show the query later on.

For
--CELKO-- Thank you for your reply.

I will give my DDL and my query on my other post, but now I'm rather
busy.

Thanks.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.