[Help] Join query from 3 tables
Hi, I'm new to database. I have a question about joining 3 tables, pardon me for my bad english.
My tables look like this
table 1: Person (id,firstname, lastname)
table 2: AssignPersonAddress (id,personid,addressid,type)
table 3: Address (id,telefon, street, etc)
I need AssignPersonAddress table, because in my data structure a person can have more than 1 address and the address type should be saved (for eg: private, work)
I want to make a select query to report all of person with his private telefon and work telefon, like this.
PERSON | PRIVATE | WORK
At the moment my query looks like this
select p.name , a1.tel AS Private, a2.tel AS Work
from person p,
addresse a1 ,
AssignPersonAddress apd1,
AssignPersonAddress apd2,
addresse a2
where p.id = apd1.person (+)
and apd1.adresse = a1.id
and apd1.art = 'Private'
and p.objectid = apd2.person (+)
and apd2.adresse = a2.id
and apd2.art = 'Work'the problem is I only get the person who has private and work address. But what I want is all person no matter if the person has only 1 address or 2 address.
As you can see I put the outer left join at the where condition, but I'm still getting the wrong result.
thx in advance
Danny
Edited by: raitodn on Oct 1, 2009 3:51 AM
Edited by: raitodn on Oct 1, 2009 4:12 AM
Hi,
You're essentially doing an inner join, because some of the comparisons are missing the + markerr.
Do this instead:
select p.name , a1.tel AS Private, a2.tel AS Work
from person p
, addresse a1
, AssignPersonAddress apd1
, AssignPersonAddress apd2
, addresse a2
where p.id = apd1.person (+)
and apd1.adresse = a1.id (+)
and apd1.art (+) = 'Private'
and p.objectid = apd2.person (+)
and apd2.adresse = a2.id (+)
and apd2.art (+) = 'Work'
;What does this mean?
where p.id = apd1.person (+)It means "include rows from p even if they don't have any matching rows in apd1". Whenever that happens, all the colummns from apd1 will be NULL.
So far, so good.
Now, what happens if you follow that with
and apd1.adresse = a1.id The condition above means "include this row from apd1 only if there is matching row in a1". If apd1 is NULL, this condition will never be TRUE (even if a1.id is NULL).
When you do a cascading outer join like this, all columns in the distal table (the table farther away from the table that must be present) need to be marked with the + sign. That includes conditions involving a constant, like
and apd1.art (+) = 'Private' By the way, when posting code or results on this site, always type these 6 characters:
(small letters only, inside curly brackets) to preserve spacing and to keep some strings, such as the outer-join marker, form being interpreted as emoticons.
Edited by: Frank Kulash on Oct 1, 2009 6:37 AM
Added explanation
Similar Messages
-
Dbms_xmlgen.newcontext query from multiple tables and ||
I have two questions
How do I get a dbms_xmlgen.context to query from multiple tables? I have been able to make it work with using one table only, but not with multiple tables.
And how to get the || (concat) to work within my query for my output to an xml file?
Here is my current query:
create or replace function get_xml return clob is
result clob;
qryctx dbms_xmlgen.ctxHandle;
SELECT DBMS_XMLGEN.getxml('select prefix, suffix, fiscal_yr
FROM rcv.recv_accessions ra
where ra.prefix = 8 and ra.fiscal_yr = 11')xml into result FROM dual;
result := DBMS_XMLGEN.getXML(qryCtx);
This is what I desire:
SELECT DBMS_XMLGEN.getxml('select ra.prefix||'-'|| ra.suffix||'-'|| ra.fiscal_yr accession, ss.date_in, st.test
FROM rcv.recv_accessions ra, ser.sero_samples ss, ser.sero_tests st
where ra.prefix = 8 and ra.fiscal_yr = 11 and ss.raid = ra.id and st.ssid = ss.id')xml into result FROM dual;
On this both the reference to multiple tables and the concat function cause errors.
Thank you
Edited by: user583094 on Mar 2, 2011 3:36 PMHi,
for the concat do I use xmlconcat?No, XMLConcat is used to concatenate XMLType fragments.
The || operator will do fine, but you must escape any single quote inside the string :
SELECT DBMS_XMLGEN.getxml(
'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = 8
AND ra.fiscal_yr = 11
AND ss.raid = ra.id
AND st.ssid = ss.id'
INTO result
FROM dual;Or, use the quoting operator to define a custom string delimiter :
SELECT DBMS_XMLGEN.getxml(
q'{SELECT ra.prefix ||'-'|| ra.suffix ||'-'|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = 8
AND ra.fiscal_yr = 11
AND ss.raid = ra.id
AND st.ssid = ss.id
INTO result
FROM dual;BTW, a good practice would be to use bind variables for the query. DBMS_XMLGEN can handle them nicely :
CREATE OR REPLACE FUNCTION get_xml
RETURN CLOB
IS
qryctx DBMS_XMLGEN.ctxHandle;
v_out CLOB;
qrystr VARCHAR2(4000) :=
'SELECT ra.prefix ||''-''|| ra.suffix ||''-''|| ra.fiscal_yr as accession,
ss.date_in,
st.test
FROM rcv.recv_accessions ra,
ser.sero_samples ss,
ser.sero_tests st
WHERE ra.prefix = :b_prefix
AND ra.fiscal_yr = :b_fiscal_yr
AND ss.raid = ra.id
AND st.ssid = ss.id';
BEGIN
qryctx := DBMS_XMLGEN.newContext(qrystr);
DBMS_XMLGEN.setBindValue(qryctx, 'b_prefix', '8');
DBMS_XMLGEN.setBindValue(qryctx, 'b_fiscal_yr', '11');
-- to generate empty elements if necessary :
DBMS_XMLGEN.setNullHandling(qryctx, DBMS_XMLGEN.EMPTY_TAG);
v_out := DBMS_XMLGEN.getXML(qryctx);
DBMS_XMLGEN.closeContext(qryctx);
RETURN v_out;
END; -
Query from source table takes lots of time
I have to load data from an Oracle table which has millions of records. The loading knowledge module I am using is 'lkm sql to oracle'.
I see that the query from the source database takes lot of time and doing a full table scan where as it supposed to be using an index.
I dont have any lkm with 'lkm oracle to oracle'. Some how I need to add a hint to this source query. How I can do this?This LKM is not indicated to large volume of data, try to use LKM Oracle to Oracle (DBLINK), see ODI KMs documentation for more information.
Related to HINTS you can add this with KM options, see that some Oracle ODI11g new KMs already have some options to do it, so you can put the hint on interface options of KM or define the temp index on the interface -
Help with select from USREXTID table
HI,
I try to select from table USREXTID and when i try to use do the select like below
SELECT bname FROM usrextid
INTO TABLE lt_bname
WHERE type = 'DN'
AND extid = temp_extid
AND status = 'X'.
here when i take the exact entry from the table i get sy-subrc = 0.
Working o.k.
when i try to use the select for SAML like
SELECT bname FROM usrextid
INTO TABLE lt_bname
WHERE type = 'SA'
AND extid = temp_extid
AND status = 'X'.
I get sy-subrc = 4.
I have entry on the table with SA and i copy all the entry from EXTID field and put it on
temp_extid ,
What can be the problem ?
Best Regards
Nina
Edited by: Nina C on Jun 15, 2009 10:05 AMHI,
i copy the entry from the table exactly and i put it ,
The problem here is with SA.
when i copy entry from table with DN it work fine.
it's behave strange .
Best Regards
Nina -
Hi,
I am having a strange issue,
i have a table containing the following amgst others
rec_time sys_date
7:00 04/08/2010
8:00 04/08/2010
9:00 05/08/2010
I need to query this table and return the max(rec_time) for all sys_date = sysdate
its not working if i do the following
select max(rec_time) from table
where sys_date = sysdate;hello,
this is my table structure for hourly_sales
ID NUMBER,
PRODUCT VARCHAR2(25 BYTE) NOT NULL,
GAME_ID NUMBER NOT NULL,
SYS_DATE DATE NOT NULL,
CONFIRMED CHAR(1 BYTE) DEFAULT 'N',
ACT_AMT NUMBER NOT NULL,
CUMM_AMT NUMBER NOT NULL,
COUNT_SALES NUMBER NOT NULL,
CREATED_BY VARCHAR2(25 BYTE),
CREATION_DATE DATE,
LAST_UPDATED_BY VARCHAR2(25 BYTE),
LAST_UPDATED_DATE DATE,
REC_TIME VARCHAR2(25 BYTE) NOT NULL,
ORDER_ID NUMBERI have created a small application in APEX that has an LOV for rec_time from 7.00 to 22.00. this is just an indication to the times that values are being entered.
Now those geezers were making mistakes and the reason why i wanted my query was to enable them to roll-back on a button click
delete from hourly_sales
where rec_time = max(rec_time)
and trunc(sys_date) = trunc(sysdate);but when i was querying it was not returning any values. -
Join rows from 2 tables with non-matching numeric intervals
Hi,
Could you please help me with the following:
I have 2 tables - [Coal_Samples] and [Coal Type] Which I have pasted below. I want to create a single result set that matches as closley as possible [Coal Type].Coal_Type to the interval between [Coal_Samples].mfrom and [Coal_Samples].mto. I would have
[Coal_Samples] as the primary table using a left outer join.
The problem is that the intervals [Coal_Samples].mfrom do not match [Coal Type].mfrom and [Coal_Samples].mto does not match [Coal Type].mto. I want to match the [Coal_Samples] intervals ([Coal_Samples].mfrom-[Coal_Samples].mto) as closely as possible to
the [Coal_Type].Coal_Type field.
I have been able to acheive this in excel using a VLOOKUP statement - but I want to know how to do this with and SQL Script without duplicating the rows based in [Coal_Samples].mfrom-[Coal_Samples].mto interval.
COAL SAMPLES TABLE
ID
mFrom
mTo
SAMPLE NUMBER
AD261
57
57.5
SAMPLE_001
AD261
57.5
58
SAMPLE_002
AD261
58
59
SAMPLE_003
AD261
59
60
SAMPLE_004
AD261
60
61
SAMPLE_005
AD261
61
62
SAMPLE_006
AD261
62
63
SAMPLE_007
AD261
63
64
SAMPLE_008
AD261
64
65
SAMPLE_009
AD261
65
66
SAMPLE_010
AD261
66
67
SAMPLE_011
AD261
67
68
SAMPLE_012
AD261
68
69
SAMPLE_013
AD261
69
70
SAMPLE_014
AD261
70
71
SAMPLE_015
AD261
71
72
SAMPLE_016
AD261
72
73
SAMPLE_017
AD261
73
74
SAMPLE_018
AD261
74
75
SAMPLE_019
AD261
75
76
SAMPLE_020
AD261
76
77
SAMPLE_021
AD261
77
78
SAMPLE_022
AD261
78
79
SAMPLE_023
COAL TYPE TABLE
ID
Type_mFrom
Type__mTo
COAL TYPE
AD261
57
68.6
BROWN COAL
AD261
68.6
75
GREY COAL
AD261
75
78.2
BLACK COAL
AD261
78.2
79.2
BLACK COAL
Example RESULT SET
ID
mFrom
mTo
DOMINANT_COAL TYPE
AD261
57
57.5
BROWN COAL
AD261
57.5
58
BROWN COAL
AD261
58
59
BROWN COAL
AD261
59
60
BROWN COAL
AD261
60
61
BROWN COAL
AD261
61
62
BROWN COAL
AD261
62
63
BROWN COAL
AD261
63
64
BROWN COAL
AD261
64
65
BROWN COAL
AD261
65
66
BROWN COAL
AD261
66
67
BROWN COAL
AD261
67
68
BROWN COAL
AD261
68
69
BROWN COAL
AD261
69
70
GREY COAL
AD261
70
71
GREY COAL
AD261
71
72
GREY COAL
AD261
72
73
GREY COAL
AD261
73
74
GREY COAL
AD261
74
75
GREY COAL
AD261
75
76
BLACK COAL
AD261
75
76
BLACK COAL
AD261
76
77
BLACK COAL
AD261
77
78
BLACK COAL
AD261
78
79
BLACK COAL
Can you please help with the logic of this query?
Thanks very much.Well, here is the beginning of the solution:
;with cte as (select S.*, T.[Coal Type] as [Dominant_Coal],
case when
T.m_from between S.m_from and S.m_to
AND T.m_to between S.m_from and S.m_to then 0
when T.m_from between S.m_from and S.m_to then t.m_from - S.m_from
else S.m_to - T.m_to end as [Diff]
from Coal_Samples S LEFT JOIN Coal_Type T
ON T.m_from between S.m_from and S.m_to
OR T.m_to between S.m_from and S.m_to),
cte1 as (select *, row_number() over (partition by cte.ID order by Diff) as Rn
from cte)
select * from cte1 where Rn = 1 -- attempt to get best match
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
I need to in SQL if possible sum the total from 6 different stores, who are all stored in a different database. I would prefer not to use a make table (again if possible) would just like a direct query using maybe CTE?
--Query 1
Select sum(emp1Sales+emp2Sales+emp3Sales+man1Sales+man2Sales)
From store1
--Query 2
Select sum(emp1Sales+emp2Sales+emp3Sales+man1Sales+man2Sales)
From store2
--Query 3
Select sum(emp1Sales+emp2Sales+emp3Sales+man1Sales+man2Sales)
From store3
...and so on.
How can I Sum all of those sales in one query? So instead of having 3 values returned have one query that returns all the values?Since its just a sum you can even do this
Select Total1 + Total2 + Total3 AS Total
FROM (
Select sum(emp1Sales+emp2Sales+emp3Sales+man1Sales+man2Sales)
As [Total1] From store1
)t1
CROSS JOIN
Select sum(emp1Sales+emp2Sales+emp3Sales+man1Sales+man2Sales)
As [Total2] From store2
)t2
CROSS JOIN
Select sum(emp1Sales+emp2Sales+emp3Sales+man1Sales+man2Sales)
As [Total3] From store3
)t3
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
I have 3 tables: Table1(Col1,Col2,Col3,Col4); Table2(Col1,Col2,Col3,Col4); Table3(Col1,Col2,Col3,Col4) and they all contain data. Now I want to have a Table4(Col1,Col2,Col3,Col4) and Table4 will contain all data of 3 tables: Table1, Table2, Table3.
Please help me to write a sql query to have the Table4.
Thanks,You just need to create view as this
CREATE VIEW View1
AS
SELECT col1, Col2, Col3, Col4 FROM Table1
UNION ALL
SELECT col1, Col2, Col3, Col4 FROM Table2
UNION ALL
SELECT col1, Col2, Col3, Col4 FROM Table3
If you want only distinct combination use UNION
CREATE VIEW View1
AS
SELECT col1, Col2, Col3, Col4 FROM Table1
UNION
SELECT col1, Col2, Col3, Col4 FROM Table2
UNION
SELECT col1, Col2, Col3, Col4 FROM Table3
Another way is using full join syntax on dummy condition
create view view1
as
select coalesce(t1.col1,t2.col1,t3.col1) as col1,
coalesce(t1.col2,t2.col2,t3.col2) as col2,
coalesce(t1.col3,t2.col3,t3.col3) as col3,
coalesce(t1.col4,t2.col4,t3.col4) as col4
from Table1 t1
full join Table2 t2
on 1=2
full join Table3 t3
on 1=2
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
i want to display the records for this day. the thing is that the data comes from 3 different tables.
the query contains the ff columns:
date tableA
entryid tableA
audittype tableA
name tableB
shift tableA
package tableC
machine tableA
tableB has
badge
name
tableC has
id
packageplease help
thanksTry this:
with tableA as
(select to_date('02-16-07','mm-dd-yy') date1, 1 entryid, 'prod' audittype, 1 badge, 'N' shift, 1 pkgid, 'Mach1' machine from dual
union all
select to_date('02-16-2007','mm-dd-yy') date1, 2 entryid, 'prod' audittype, 2 badge, 'N' shift, 2 pkgid, 'Mach1' machine from dual),
tableB as
(select 1 badge, 'Amy' name1 from dual
union all
select 2 badge, 'Zach' name1 from dual),
tableC as
(select 1 pkgid, 'Pkg1' package1 from dual
union all
select 2 pkgid, 'Pkg2' package1 from dual)
select a.date1, a.Entryid, a.Audittype, b.name1 Name, a.Shift, c.package1 Pkg, a.Machine
from tableA a
join tableB b
on a.badge = b.badge
join tableC c
on a.Pkgid = c.pkgid; -
Hierarchical Query from 4 tables
Hi,
I'm using database 10.2.0.1.0.
I have 4 tables . The data
SQL> select * from table1;
TT1
1
2
3
4Where tt1 is a number column
SQL> Select * from table2;
TT1 TT2
1 x
1 y
2 a
3 testing search
SQL> Select * from table3;
TT1 TT2 TT3
1 x xy
1 x xz
1 y yn
2 a ax
SQL> Select * from table4;
TT1 TT2 TT3 TT4
1 x xy testing for the width expansion
1 x xz testing
1 y yn ynx
2 a ax axy
2 a ax axzFrom these table i want to write a hierarchichal query to populate a tree , such that the tree looks like
1
-- x
-- testing for the width expansion
-- testing
-- y
-- ynx
2
-- a
-- axy
-- axz
3
-- testing search
4Note: Table3's data is not shown in the tree, but is used indirectly to get the data from table4.
Please help
ThanksYes, that's the script.
Sample output for you:
SQL> SELECT LPAD(' ', 2*level) || granted_role "USER PRIVS"
FROM (
SELECT NULL grantee, username granted_role
FROM dba_users
WHERE username LIKE UPPER('system')
UNION
SELECT grantee, granted_role
FROM dba_role_privs
UNION
SELECT grantee, privilege
FROM dba_sys_privs)
START WITH grantee IS NULL
CONNECT BY grantee = prior granted_role;
USER PRIVS
SYSTEM
AQ_ADMINISTRATOR_ROLE
CREATE EVALUATION CONTEXT
CREATE RULE
CREATE RULE SET
DEQUEUE ANY QUEUE
ENQUEUE ANY QUEUE
MANAGE ANY QUEUE
CREATE MATERIALIZED VIEWWould this work?
//Johan -
DI UI : fill matrix with a query from user table data
hello,
I create a user table.
I want to fill a matrix on a form with some aggregated data of this user table.
I do :
Public Sub SetMatrixRep()
Dim oRecordSet As SAPbobsCOM.Recordset
Dim oCentre As SAPbouiCOM.EditText
Dim oCompte As SAPbouiCOM.EditText
Dim oBudget As SAPbouiCOM.EditText
Dim oDepense As SAPbouiCOM.EditText
Dim oSolde As SAPbouiCOM.EditText
Dim i As Long
i = 0
Set oRecordSet = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRecordSet.DoQuery ("select * from [@CAP_OPRC_BUDGET]")
While oRecordSet.EOF = False
' filling the matrix
Set oCentre = oMatrixRep.Columns("clCentre").Cells.Item(i).Specific
oCentre.String = oRecordSet.Fields.Item(0).Value
'oMatrixRep.Columns("clCentre").Cells(1).Specific.String = oRecordSet.Fields.Item(0).Value
'SBO_Application.MessageBox (oRecordSet.Fields.Item(0).Value)
oMatrixRep.AddRow
oRecordSet.MoveNext
i = i + 1
Wend
End Sub
I've got an error : Row - Index invalid.
Could you help me please ?
Thanks.
Romeo.Hi
This is a routine that I call from my Item Event handler
Hope it can help you
Public Sub PopolaMatrice(oApplicazione As SAPbouiCOM.Application, pVal As SAPbouiCOM.IItemEvent)
Dim oForm As SAPbouiCOM.Form
Dim oMatrix As SAPbouiCOM.Matrix
Dim oDBDataSource As SAPbouiCOM.DBDataSource
Dim oConditions As New SAPbouiCOM.Conditions
Dim oCondition As SAPbouiCOM.Condition
Dim oDocNum As SAPbouiCOM.EditText
Dim lIndice As Long
Set oForm = oApplicazione.Forms.GetFormByTypeAndCount(pVal.FormType, pVal.FormTypeCount)
Set oDBDataSource = oForm.DataSources.DBDataSources.Item("MyUserTableName")
Set oMatrix = oForm.Items("MyMatrixName").Specific
oMatrix.Clear
'setting the condition object
'this is equal to the following SQL statement
'WHERE UserFieldName1 = "MyCriteria1" and UserFieldName2 = "MyCriteria2"
Set oCondition = oConditions.Add()
oCondition.BracketOpenNum = 2
oCondition.Alias = "UserFieldName1"
oCondition.Operation = co_EQUAL
oCondition.CondVal = "MyCriteria1"
oCondition.BracketCloseNum = 1
oCondition.Relationship = cr_AND
Set oCondition = oConditions.Add()
oCondition.BracketOpenNum = 1
oCondition.Alias = "UserFieldName2"
oCondition.Operation = co_EQUAL
oCondition.CondVal ="MyCriteria2"
oCondition.BracketCloseNum = 2
oDBDataSource.Query oConditions
'filling the matrix
For lIndice = 0 To oDBDataSource.Size - 1
oDBDataSource.Offset = lIndice
oMatrix.AddRow
Next lIndice
End Sub -
Hi i have got this query that is a join of two tables but i need join for three tables i need the extended query
select aauthlname aauthlnam aauthfname aauthfnam aisbn btitle
from ( bsauthors as a inner join bsbook as b on aisbn = bisbn )
into corresponding fields of table books
where aauthlname like authorlname or aauthfname like authorfname
order by aauthlname aauthfname a~isbn.Hi pavan
Plz try the following querry for joins on three tables :
" Customize it to ur requirements and tablenames
Parameters : b type mara-matnr.
select xmatnr xmtart xmatkl ywerks ylgort zmaktx
into corresponding fields of table itab
from ( ( mara as x inner join mard as y on xmatnr = ymatnr )
inner join makt as z on xmatnr = zmatnr ) where x~matnr = a and
y~werks
= b .
Plz see that there is atleast one field common between the three tables u want to use.
Regards
Pankaj -
Need help with query from .csv file
I am trying to import a csv file with only 1 column in it.
The column will only contain a 9 digit ID number. I want to read
the file then use the contents to query a table to get the names
and other information and display it. Here is what I have so far:
<cffile action="read" file="#form.FiletoUpload#"
variable="csvfile">
<cfloop index="index" list="#csvfile#">
<cfquery name="massimport" datasource="data1">
SELECT * FROM IDTable
WHERE CardNumber = ('#csvfile#')
</cfquery>
</cfloop>
<cfoutput>#Name# #ID# #Site#</cfoutput>
I get no errors but I am not getting any results. Just a
blank page. Does anyone know how to query directly from a csv
import? Thanks.You need to convert your file to a list somehow. Not sure if
this is the most efficient way but, you can use the cfhttp tag to
produce a query. Then your where clause becomes,
where cardnumber in (#quotedvaluelist(query.column)#)
and you won't need a loop. -
Interactive Reporting - Chg Query from Using Table to Result Set w/ same Co
Currently I have a query that uses an Oracle table. I would like to change the query to use the result set of another query wh/ contains the same information & column names (however, since I am creating the results from scratch, I don't have to wait for the Oracle table to be updated). Is there a way to do this change w/o IR automatically removing the column names from the results and then making me go back into each result set and re-adding them, formatting them, etc. For example, the query currently uses a table called Defect_History, wh/ has columns bug_id, application, sub-app, etc. This table is not updated on a daily basis, so I have created a new query wh/ goes against the source tables used in creating the Defect_History table and puts the latest information into an IR result set. Is there a way to change the current queries that use the Defect_History table to use the IR result set instead w/o basically recreating each of the subsequent queries? I have gone into Dashboard Studio Optimize Utility, but the queries show as using Data Model, Data Model2, etc as the Parent and I am not able to make changes to it.
Thanks.
TerriI am in the Dashboard Studio - Optimize Utility. When I select that report (or any of the others), the Reparent button is grayed out on the toolbar. I've also tried right-clicking on the report and it's grayed out there as well. Any ideas?
-
Join resuslt from different table
I have table A:
col 1 | Col 2
AC11 AC21
and table B:
col 1 | Col 2
BC11 BC21
I need a select statement that'll return
RESULT:
AC11 | AC12 | BC11 | BC12
is this possible?Continuing with my above post:
But if there are more then 1 rows in each table then there will be a problem so a common field (foreign key) will be required for proper results using join.
with table1 as (select 'AC11' col1, 'AC21' col2
from dual
union
select 'AC111' col1, 'AC211' col2
from dual),
table2 as (select 'BC11' col1, 'BC21' col2
from dual
union
select 'BC111' col1, 'BC211' col2
from dual)
select table1.col1, table1.col2, table2.col1, table2.col2
from table1, table2
COL1 COL2 COL1_ COL2_
AC11 AC21 BC11 BC21
AC11 AC21 BC111 BC211
AC111 AC211 BC11 BC21
AC111 AC211 BC111 BC211
4 rows selected.Instead of 2 the output will be 4 records as there is no JOIN condition.
Best Regards
Arif Khadas
Maybe you are looking for
-
Printing Barocdes on XML Publisher output
Hii, My requirement is to print the barcodes for few fields in the output. We have developed the report in XML Publisher 5.6.3. As per Oracle i need to create a Class file and then Call that Class file from Template. I am done with the Class file wit
-
How do i use multiple appleIDs on my ipad?
I have a macbook pro. my husband has an iphone. he bought me an ipad but used his appleID for the initial setup. now i cannot figure out how to sync the ipad to my macbook or how to add my appleID to my ipad. we were hoping we could share the ipad. a
-
I've connected two different displays to my powerbook. The computer recognises the existance of the display, but the screens stay black showing no input signal. It used to work properly. I thought there was a trick to overcome this problem but couldn
-
How to Improve Perfomance of JavaApp with several tabs in JDeveloper
Hi, One of my screens in my java application has several tabs. The master detail relationship is defined in a MDPanel using bindNestedContainer/findNestedPanelBinding constructs. If there are several wiews being linked to the master record, performan
-
Hi, In the attached file, I have 2 problems: I learn from MR Excel book, and I try to calculate the highest profit for each sector with the condition that the Quantity is less then 500 I used this measure: Measure 1:=maxx(Sales[Profit],[Quantity]<500