Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Join problem

Author  Topic 

lesbail
Starting Member

3 Posts

Posted - 2009-02-06 : 05:07:43
I have managed with help from the forum thx
to create a view of all my databases together by using the following script:-
SELECT agroup.scheme.slitemm.customer, agroup.scheme.slitemm.item_no, agroup.scheme.slitemm.refernce, agroup.scheme.slitemm.dated,
agroup.scheme.slitemm.due_date, agroup.scheme.slitemm.kind, agroup.scheme.slitemm.amount, agroup.scheme.slitemm.currency_amount,
agroup.scheme.slitemm.vat_amount, agroup.scheme.slitemm.open_indicator, agroup.scheme.slitemm.customer_order_num,
agroup.scheme.slitemm.effective_date, agroup.scheme.slitemm.order_customer, agroup.scheme.slitemm.spare, agroup.scheme.slcustm.name
FROM agroup.scheme.slitemm CROSS JOIN
agroup.scheme.slcustm
WHERE (agroup.scheme.slitemm.open_indicator = 'O')
UNION ALL
SELECT slitemm_1.customer, slitemm_1.item_no, slitemm_1.refernce, slitemm_1.dated, slitemm_1.due_date, slitemm_1.kind, slitemm_1.amount,
slitemm_1.currency_amount, slitemm_1.vat_amount, slitemm_1.open_indicator, slitemm_1.customer_order_num, slitemm_1.effective_date,
slitemm_1.order_customer, slitemm_1.spare, slcustm_1.name
FROM emerg1.scheme.slitemm AS slitemm_1 CROSS JOIN
emerg1.scheme.slcustm AS slcustm_1
WHERE (slitemm_1.open_indicator = 'O')
Unfortunately I am getting duplicates from my databases I know this will be a join issue but dont know enough about sql to find the answer.

Any help woud be much appreciated
Thanks in advance
Les

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-06 : 05:08:54
quote:
Originally posted by lesbail

I have managed with help from the forum thx
to create a view of all my databases together by using the following script:-
SELECT agroup.scheme.slitemm.customer, agroup.scheme.slitemm.item_no, agroup.scheme.slitemm.refernce, agroup.scheme.slitemm.dated,
agroup.scheme.slitemm.due_date, agroup.scheme.slitemm.kind, agroup.scheme.slitemm.amount, agroup.scheme.slitemm.currency_amount,
agroup.scheme.slitemm.vat_amount, agroup.scheme.slitemm.open_indicator, agroup.scheme.slitemm.customer_order_num,
agroup.scheme.slitemm.effective_date, agroup.scheme.slitemm.order_customer, agroup.scheme.slitemm.spare, agroup.scheme.slcustm.name
FROM agroup.scheme.slitemm CROSS JOIN
agroup.scheme.slcustm
WHERE (agroup.scheme.slitemm.open_indicator = 'O')
UNION ALL
SELECT slitemm_1.customer, slitemm_1.item_no, slitemm_1.refernce, slitemm_1.dated, slitemm_1.due_date, slitemm_1.kind, slitemm_1.amount,
slitemm_1.currency_amount, slitemm_1.vat_amount, slitemm_1.open_indicator, slitemm_1.customer_order_num, slitemm_1.effective_date,
slitemm_1.order_customer, slitemm_1.spare, slcustm_1.name
FROM emerg1.scheme.slitemm AS slitemm_1 CROSS JOIN
emerg1.scheme.slcustm AS slcustm_1
WHERE (slitemm_1.open_indicator = 'O')
Unfortunately I am getting duplicates from my databases I know this will be a join issue but dont know enough about sql to find the answer.

Any help woud be much appreciated
Thanks in advance
Les



Jai Krishna
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-06 : 05:14:02
You also know that a CROSS JOIN is the same thing as a Cartesian Product?
http://en.wikipedia.org/wiki/Cartesian_product



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -