Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,

I need help with the below code -

I have 2 tables - A and B

A | B
====================
1 | 1
2 | 2
3 | 3

All i need is the row(1) from table A should be allowed to merge with row(2) and row(3) in tableB, likewise tableA row(2) should be allowed to merge with row(1) and row(3) of tableB and tableA row(3) should be allowed to merge with row(1) and row(2) of tableB.
[this is just an example]

What I have tried:

I tried to use

$array = array('1=>1','2=>2','3=>');
$query ="select A from table where B='".$T."' union all select B from table where A='".$T."'";
$stid = oci_parse($conn,$query);
$row = oci_execute($stid);
$row = oci_fetch_row($stid);
$oci_free_statement($stid);

I am not able to sure if we need to use slice/intersect/subset.
I have been trying to sort this using OCI_bind_by_array as well but no go, i have spent 3days but unable to find a solution.
Posted
Updated 5-Nov-18 9:39am
Comments
Richard Deeming 2-Nov-18 13:01pm    
What's the expected output? Are you just looking for the cross-product of the two tables?
Member 11089603 5-Nov-18 2:29am    
Yes i am looking for cross product of the two tables..
something like

row(1) from table A should be allowed to merge with row(2) and row(3) in tableB, likewise tableA row(2) should be allowed to merge with row(1) and row(3) of tableB and tableA row(3) should be allowed to merge with row(1) and row(2) of tableB.

1 solution

It sounds like you're looking for the CROSS JOIN operator[^].
SELECT * FROM A CROSS JOIN B

This will produce the cross product of both tables:
A | B
=====
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
2 | 3
3 | 1
3 | 2
3 | 3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900