ANSI SQL Syntax - What belongs to join-clause and what to where-clause
Hello,
we currently have a discussion about the ANSI SQL Syntax where we do not agree what belongs to the join clause and what belongs to the where clause in an ANSI Sytnax SQL Query.
Lets say there is a query like this:
+SELECT *+
FROM employees emp, departments dept
WHERE emp.dept_country = dept.dept_country
AND emp.dept_name = dept.dept_name
AND dept.dept_type = 'HQ'
AND emp.emp_lastname = 'Smith'
Primary key of the departments table is on the columns dept_country, dept_name and dept_type. We have a Oracle database 10g.
Now I have rewritten the query to Ansi Syntax:
+SELECT *+
FROM employees emp
JOIN departments dept
ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name
WHERE dept.dept_type = 'HQ'
AND emp.emp_lastname = 'Smith'
Another developer says that this is not completely correct, every filter on a column that belongs to the primary-key of the joined table has to be in the join clause, like this:
+SELECT *+
FROM employees emp
JOIN departments dept
+ON emp.dept_country = dept.dept_country AND emp.dept_name = dept.dept_name AND dept.dept_type = 'HQ'
WHERE emp.emp_lastname = 'Smith'
Can somebody tell me which on is correct?
Is there any definition for that? I couldn't find it in the Oracle Database definition.
I just found out the names of the ANSI documents here: http://docs.oracle.com/cd/B19306_01/server.102/b14200/ap_standard_sql001.htm#i11939
I had a look at the ANSI webstore but there you have to buy the PDF files. In my case thats exaggerated because both of the Queries work and i am just interessted if there is one correct way.
Thank you in advance
Marco
Hi,
As i guideline i would say, answer the question: should the result of the join be filtered or should only filtered rows be joined from a particular table?
This is helpful in the case of outer joins also, for inner joins it doesnt matters as said already be former posters, where there may be hughe semantical differences depending of where the predicates are placed.
From performance view, if we talk about oracle, take a look a the execution plans. You will see that there is (probably) no difference in case of inner joins. Even in case of outer joins the optimizer pushes the predicate as a filter towards the table if it semantically possible.
Regards
Similar Messages
-
Hi all,
I have a simple query
SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
WHERE ALTERNATE_REF LIKE 'PF%'
AND A.alt_ref_code = B.Equip_No
AND B.Dstrct_Code = 'ACME';
which works fine, but I want to convert it to ANSI
SQL syntax, so I tried
SELECT A.*, B.Dstrct_Code FROM MSF601 A, MSF600 B
WHERE ALTERNATE_REF LIKE 'PF%'
INNER JOIN ON A.alt_ref_code = B.Equip_No
AND B.Dstrct_Code = 'ACME';
but I get
ERROR at line 3:
ORA-00933: SQL command not properly ended
Could some kind soul explain why?
Paul...An example that looks a lot like your example:
SQL> select dept.*
2 , emp.ename
3 from dept, emp
4 where dept.dname like '%A%'
5 inner join on dept.deptno = emp.deptno
6 and emp.sal > 1000
7 /
inner join on dept.deptno = emp.deptno
FOUT in regel 5:
.ORA-00933: SQL command not properly ended
SQL> select dept.*
2 , emp.ename
3 from dept
4 inner join emp on dept.deptno = emp.deptno
5 where dept.dname like '%A%'
6 and emp.sal > 1000
7 /
DEPTNO DNAME LOC ENAME
30 SALES CHICAGO ALLEN
30 SALES CHICAGO WARD
20 RESEARCH DALLAS JONES
30 SALES CHICAGO MARTIN
30 SALES CHICAGO BLAKE
10 ACCOUNTING NEW YORK CLARK
20 RESEARCH DALLAS SCOTT
10 ACCOUNTING NEW YORK KING
30 SALES CHICAGO TURNER
20 RESEARCH DALLAS ADAMS
20 RESEARCH DALLAS FORD
10 ACCOUNTING NEW YORK MILLER
12 rijen zijn geselecteerd.Regards,
Rob. -
How to generate ANSI SQL syntax mapping
I am not able to force OWB to generate ANSI SQL syntax mapping.
In mapping configuration I have checked "ANSI SQL syntax" On, "Operating mode" is "Set based fail over to row based", "Optimize code" is On.
"PLSQL generation mode" is set to 10gR2.
OWB 10.2.0.4.36, OraDB 10.2.0.4.0Oracle SQL is based on ANSI sql 92 standards. But not possible to generate queries in ansi sql 92 format?
-
Hi,
Is there a performance difference between ansi and old syntax.
The following query
SELECT ITD.display_description
FROM structure_child SC
RIGHT OUTER JOIN structure S ON SC.structure_id = S.structure_id
INNER JOIN structure_level SL ON SL.structure_level_id = S.structure_level_id
INNER JOIN item_type_naming ITN ON ITN.structure_id = S.structure_id
INNER JOIN item_type_description ITD ON ITN.item_type_description_id = ITD.item_type_description_id
AND item_type_id = p_item_type_id
WHERE ( S.structure_id = p_structure_id OR S.structure_id = 0)
and itd.item_type_id = p_item_type_id
ORDER BY structure_level
Runs much slower than the old style query
SELECT ITD.DISPLAY_DESCRIPTION
FROM structure S, structure_child SC, structure_level SL,item_type_naming ITN,
item_type_description ITD
WHERE SC.structure_id(+) = S.structure_id
AND SL.structure_level_id = S.structure_level_id
AND ITN.structure_id = S.structure_id
AND ITN.item_type_description_id = ITD.item_type_description_id
AND item_type_id = p_item_type_id
AND (S.structure_id = p_structure_id OR S.structure_id = 0)
ORDER BY structure_level
Any reasons why this is the case. Also is there any hint I can give to improve the performance.They ought to be the same.
Be sure to run the query twice to ensure the extra time doesn't including parsing, etc.
Do you get the same results?
Are the explain/execution plans the same?
The only caveat I can think of with ANSI joins is that there is a problem using them over a dblink in which one of the remote tables has a LOB column, an error is generated it that case...
Steve -
Hey,
one of my colleagues managed to create a SQL-statement (in ansi-sql-syntax) that just blocks the session and gives no response at all.
When I rewrote the statement, it gave results within a second.
It's not quite possible to provide a sample-case, but maybe someone here has an idea why the first statement doesn't work, and the second does?
First:
====
SELECT c.CONTRACTID as ENTITEITID,
v.VASTSTELLINGCODE,
'' as INFO,
v.CAMPAGNE
FROM NFD_CONTRACT c
INNER JOIN NFD_OVK o ON o.OVKID = c.OVKID
INNER JOIN NFD_VSTDEFCMP v ON v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
INNER JOIN NFD_BETROKKENPSN_CON psn ON c.CONTRACTID = psn.CONTRACTID
INNER JOIN (SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
else 0
end AS OA_Heeft_E
FROM NFD_AANGIFTE a
WHERE AANGIFTETYPE = 'Oogstaangifte') vst ON psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1
Second:
======
SELECT c.CONTRACTID as ENTITEITID,
v.VASTSTELLINGCODE,
'' as INFO,
v.CAMPAGNE
FROM NFD_CONTRACT c
,nfd_ovk o
,nfd_vstdefcmp v
,nfd_betrokkenpsn_con psn
,(SELECT a.aangifteid, a.psn_nmr, a.psnrolid, a.oogstjaar,
case when exists (SELECT ENTITEITID FROM NFD_VST_OA04_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA04M_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA04S_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA05_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
when exists (SELECT ENTITEITID FROM NFD_VST_OA06_V vst WHERE a.AANGIFTEID = vst.ENTITEITID) then 1
else 0
end AS OA_Heeft_E
FROM NFD_AANGIFTE a
WHERE AANGIFTETYPE = 'Oogstaangifte') vst
WHERE o.OVKID = c.OVKID
AND v.VASTSTELLINGCODE = 'C77' AND v.CLASSIFICATIECODE = o.CLASSIFICATIECODE AND v.CAMPAGNE = o.CAMPAGNE
AND Nfd_Vaststellingen_Pck.NFD_IS_DATUM_VST_VALID('C77',o.CAMPAGNE,'Contract',o.CLASSIFICATIECODE) = 1
AND c.CONTRACTID = psn.CONTRACTID
AND psn.PSN_NMR = vst.PSN_NMR AND psn.PSNROLID = vst.PSNROLID
AND o.CAMPAGNE = vst.OOGSTJAAR AND vst.OA_Heeft_E = 1hey riedelmie,
off course the second statement is different.
I rewrote the query so the inner joins are being replaced by where-clauses with the table-names all in the from-clause.
In the second statement there are two extra when-clauses but they should also be in the first statement (the problem is still there, so data could indeed be different, but the problem is the same)
Tnx.
Greetings,
Dave
Message was edited by:
geysemansdave
added text about the when-clauses -
Ansi SQL for "select ... for update nowait"
Hi, All,
I have a sql
select ... for update nowait
My boss wants it to be ANSI compliant.
I am not familiar with ANSI SQL.
What should be the syntax in Ansi?
Thanks a lot!I resent having the lowest salary :-)Sorry John, it's probably due to the exchange rate of sterling against the canuck dollar right now.
SQL> select empno, ename, sal, job, mgr from emp;
EMPNO ENAME SAL JOB MGR
7369 SPENCER 800 CLERK 7902
7499 VERREYNNE 1600 SALESMAN 7698
7521 VAN WIJK 1250 SALESMAN 7698
7566 MAINGUY 2975 MANAGER 7839
7654 KISHORE 1250 SALESMAN 7698
7698 BARRY 2850 MANAGER 7839
7782 BOEHMER 2695 MANAGER 7839
7788 PADFIELD 3000 ANALYST 7566
7839 SCHNEIDER 5500 PRESIDENT
7844 GASPAROTTO 1500 SALESMAN 7698
7876 CAVE 1100 CLERK 7788
7900 CLARKE 950 CLERK 7698
7902 JAFFAR 3000 ANALYST 7566
7934 ROBERTSON 1430 CLERK 7782
14 rows selected.
SQL> Cheers, APC -
Can someone kindly tell me the correct syntax for this statement?
String sql = "UPDATE answers SET q1 = '" + value + "'" + "WHERE EXISTS (SELECT * FROM users u, answers a WHERE u.username = a.username)";
int numRows = stmt.executeUpdate(sql);
The error I am getting is:
Caught SQL Exception: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax near 'EXISTS SELECT * FROM users u, answers a WHERE u.username = a.username' at line 1I am using a cookie instead. But, when I use an update, my values are the same for each column, not the appropriate values. Is my syntax below correct?
String delete = request.getParameter("delete");
String question = request.getParameter("question");
String value = request.getParameter("R");
Cookie[] cookies = request.getCookies();
if (delete.equals("no") && !value.equals(""))
if(cookies != null)
for (int i = 0; i < cookies.length; i++)
String name = cookies.getName();
String valuecook = cookies[i].getValue();
//Cookie getUser = new Cookie(name, valuecook);
String sql = "UPDATE answers SET q1 ='" + value + "' " + "WHERE USERNAME = '" + valuecook + "'";
int numRows = stmt.executeUpdate(sql);
String sql2 = "UPDATE answers SET q2 ='" + value + "' " + "WHERE USERNAME = '" + valuecook + "'";
int numRows2 = stmt.executeUpdate(sql2);
String sql3 = "UPDATE answers SET q3 ='" + value + "' " + "WHERE USERNAME = '" + valuecook + "'";
int numRows3 = stmt.executeUpdate(sql3);
out.println(value);
out.println(valuecook);
// UPDATE table_name SET column_name1 = value1 [, column_name2 = value2, etc.] WHERE criteria
out.println("Record has been inserted");
String nextPage = request.getParameter("nextPage"); -
ANSI SQL 92 SYNTAX OUTER JOIN PERFORMANCE ISSUE
Good Morning
Could anyone explain why the excution time for these two (ment to be identical)
queries run so differently.
oracle syntax execution time 1.06 seconds
select COUNT(*) from
PL_EVENT_VIEW pev,
PL_EVENT_STAFF_VIEW pesv
WHERE pev.EVENT_ID=PESV.EVENT_ID(+)
AND pev.WEEKS=PESV.WEEK_NUM(+)
AND pev.event_id=2520
ansi sql 92 syntax execution time 7.05 seconds
select COUNT(*) from
PL_EVENT_VIEW pev
LEFT JOIN PL_EVENT_STAFF_VIEW pesv
ON (pev.EVENT_ID=PESV.EVENT_ID
AND pev.WEEKS=PESV.WEEK_NUM)
WHERE pev.event_id=2520
Thanks
David HillsBTW Oracle outer join operator (+) and ANSI SQL OUTER JOIN syntax are NOT equivalent. Consider following:
DROP TABLE T1;
CREATE TABLE T1 (C1 NUMBER);
DROP TABLE T2;
CREATE TABLE T2 (C2 NUMBER);
DROP TABLE T3;
CREATE TABLE T3 (C3 NUMBER);
-- Following SELECT works:
SELECT COUNT(*)
FROM T1, T2, T3
WHERE C2 = C1
AND C3(+) = C1
COUNT(*)
0
-- But:
SELECT COUNT(*)
FROM T1, T2, T3
WHERE C2 = C1
AND C3(+) = C1
AND C3(+) = C2
AND C3(+) = C1
ERROR at line 4:
ORA-01417: a table may be outer joined to at most one other table
-- However with ANSI syntax:
SELECT COUNT(*)
FROM T1
JOIN T2 ON (C2 = C1)
LEFT JOIN T3 ON (C3 = C1 AND C3 = C2)
COUNT(*)
0 -
What is Difference between ANSI SQL and ORACLE SQL
Hi,
I am going to take the assesment test for ANSI SQL Programming before that i want to know any difference between ANSI SQL and ORACLE SQL?
I am studying for SQL but the test will be ANSI SQL please let me give an idea about the both.
Thanks
Merina RoslinBasically there is syntax difference between both of them.
Lets say i want to join two table EMP and DEPT based on DEPTNO.
With Oracle SQL format its like this.
select e.*
from emp e, dept d
where e.deptno = d.deptnoHere the joining condition goes in the WHERE clause.
With ANSI SQL format its like this.
select e.*
from emp e
join dept d
on e.deptno = d.deptnoHere the join condition is mentioned separately and not in WHERE clause.
Oracle supports ANSI SQL starting from 9i version.
You can read more about the syntax difference Here -
Converting oracle join to Ansi sql join
Hi Guys,
I am new to SQL and trying to convert the following Oracle query (joins) into ANSI sql joins...Can someone please help me?
SELECT M.EXTERNALCODE, M.NAME AS MNAME, SC.BIRIM, SM.TRANSACTIONDATE, SMD.AMOUNT,
SMD.UNITPRICE, SM.ID AS SMID, SMD.ID AS SMDID, F.NAME AS FNAME,
IFNULL (SMD.AMOUNT, 0, SMD.AMOUNT) * IFNULL (SMD.UNITPRICE, 0, SMD.UNITPRICE) AS TOTALPRICE, SMD.AMOUNT AS RECEIVED_QUANTITY,
PD.ORDERID, PD.AMOUNT QUANTITY, PO.PROCESSDATE
FROM STOCKMAINTRANSACTION SM,
STOCKMAINTRANSACTIONDETAIL SMD,
MATERIAL M,
STOCKCARD SC,
FVSTOCK FVS,
FIRM F,
PURCHASEORDER PO,
PURCHASEORDERDETAIL PD,
PURCHASEORDERDETAILSUPPLIED PDS
WHERE SM.ID = SMD.MAINTRANSACTIONID
AND SMD.MATERIALID = M.ID
AND SMD.STOCKCARDID = SC.ID
AND SM.PROPREF = FVS.RECORDID(+)
AND FVS.FIELDID(+) = 2559
AND FVS.FLEVEL(+) = 'F'
AND F.ID(+) = SUBSTR (FVS.FVALUE, 1, 9)
AND SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)
AND SMD.CANCELLED = 0
AND SMD.STOCKUPDATED = 1
AND SMD.ID = PDS.STOCKMAINTRANSACTIONDETAILID
AND PDS.ORDERDETAILID = PD.ORDERDETAILID
AND PO.ORDERID = PD.ORDERID
AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}
ORDER BY F.NAME, M.EXTERNALCODE, SM.TRANSACTIONDATE
Really appreciate the help!
Thanks.Hi,
Welcome to the forum!
To convert to ANSI syntax, replace join conditions in the WHERE clause
FROM x
, y
WHERE x.x1 = y.y1
AND x.x2 = y.y2with ON conditions in the FROM clause:
FROM x
JOIN y ON x.x1 = y.y1
AND x.x2 = y.y2In inner joins, conditions that do not reference 2 tables are not really join conditions, so it doesn't matter if they are in the FROM clause or in the WHERE clause.
In your case
SM.TRANSDEFID in (999,2329,2344,2370,150000903,150005362)could be part of a join condition involving sm, or it could be in the WHERE clause. Most people find it clearer if 1-table conditions like this are in the WHERE clause.
Again, this only applies to inner joins. For outer joins, all conditions that apply to a table that may lack matching rows must be included in the FROM clause, like this:
LEFT OUTER JOIN fvstock fvs ON sm.propref = fvs.recordid
AND fvs.fieldid = 2559
AND fvs.flevel = 'F'Try it.
If you have trouble, post your best attempt, along with CREATE TABLE and INSERT statements for a little sample data from all the tables involved, and the results you want from that data. Simplify the problem. Post only the tables and columns that you don't know how to handle.
See the forum FAQ {message:id=9360002}
user8428528 wrote:
AND (M.ID = {@MATERIALID@} OR {@MATERIALID@} = 0)
AND (SM.STOREID = {@STOREID@} OR {@STOREID@} = 0)
AND (F.ID = {@SUPPLIERID@} OR {@SUPPLIERID@} = 0)
AND SM.TRANSACTIONDATE BETWEEN {@STARTDATE@} AND {@ENDDATE@}This is not valid Oracle SQL. Is {@MATERIALID@} some kind of variable? -
Haven't seen a solution to this on the forum or in the docs. My last post timed out with no responses, but I still don't know if I have a possible solution.
I've got 2 objects, Task and Role, that are linked in a M-M relationship.
My tables are:
T_TASKS
T_TASKSROLES
T_ROLES
I am querying T_TASKS and joining on T_TASKSROLES and T_ROLES, but I need to use an outer join because not all Tasks have a Role in T_TASKSROLES.
In SQL Server, my FROM clause SHOULD look like this:
FROM (T_TASKSROLES t2 LEFT OUTER JOIN T_TASKS t1 ON t1.ID = t2.TASKID) LEFT OUTER JOIN T_ROLES t0 ON t0.ID = t2.ROLEID
however, if I use eb.anyOfAllowingNone(_roles) in my ExpressionBuilder. TopLink creates a LEFT OUTER JOIN clause that looks like this:
FROM T_ROLES t0 LEFT OUTER JOIN T_TASKS t1 ON((t0.ID = T_TASKSROLES.ROLEID) AND (t1.ID = T_TASKSROLES.TASKID))
I can see the logic in how it builds this clause. But, it doesn't parse in SQL Server.
Is there a way to effect how TopLink generates the FROM clause for outer joins? I mean, I understand how to use the XXXPlatform.java source files and can change whether to use OuterJoin in the WHERE clause or not. But, I can't see anything in the platform class that would allow me to figure this out.
I realize I could write SQL manually, but is there a way to do this so that the same code would work on SQL Server, Oracle, and Sybase (assuming the DatabaseLogin is configured appropriately)?
It just seems like LEFT OUTER JOIN when joining M-M relationships isn't generating proper SQL. Is the TopLink SQL SQL92-compliant?
I should add that I have tried to change SQLServerPlatform to have shouldPrintOuterJoinInWhereClause() return "true". This embeds a "=*" in the join conditions in the WHERE clause.
SQL Server 2000 still supports this syntax, but the "=*" isn't ALWAYS the correct operator. It is important to put the "*" on the correct side of the expression. TopLink always prints "=*", but the operators are not always in the correct order. So, it tries to create a "left join" on the wrong table.
So my other question, is it possible to force TopLink to remember to put the outer join table in the RIGHT SIDE?
NateThe workaround is actually more complicated than that, and it can't be fixed by changing only the operator.
In the queries you listed, the only difference is which side of the "AND" the expressions appear on.
Change "(t2.rightid (+)= t1.rightid)" to "(t1.rightid (+)= t2.rightid)" and I'm guessing (although not sure because I am testing with SQL Server at the moment), that you'll get a similar query error as I did.
The bug here is that the default M-M selection criteria creates "reltable = table1 AND table2 = reltable". There is no operator that can satisfy this expression.
So, the fix that I made, for all of my M-M Mappings was to set the SelectionCriteria manually using the following Expression (returned from this method):
// This puts M-M relationship tables on the same side of expressions so that OUTER JOINS can be supported.
private Expression getSameSideExpression() {
// target side
Expression selectionCriteria = null;
Enumeration e2 = getTargetKeyFields().elements();
Enumeration e = getTargetRelationKeyFields().elements();
ExpressionBuilder eb = new ExpressionBuilder();
Expression relTableExp = null;
while(e2.hasMoreElements()) {
DatabaseField df = (DatabaseField) e.nextElement();
DatabaseField df2 = (DatabaseField) e2.nextElement();
if(relTableExp == null){
relTableExp = eb.getTable(df.getTable());
Expression targetFieldExp = eb.getField(df2);
Expression relFieldExp = relTableExp.getField(df);
Expression joinExp = relFieldExp.equal(targetFieldExp);
if(selectionCriteria == null)
selectionCriteria = joinExp;
else
selectionCriteria = joinExp.and(selectionCriteria);
// source side
e = getSourceRelationKeyFields().elements();
e2 = getSourceKeyFields().elements();
while(e.hasMoreElements()) {
DatabaseField df = (DatabaseField) e.nextElement();
DatabaseField df2 = (DatabaseField) e2.nextElement();
Expression relFieldExp = relTableExp.getField(df);
Expression sourceFieldExp = eb.getParameter(df2);
Expression joinExp = relFieldExp.equal(sourceFieldExp);
if(selectionCriteria == null)
selectionCriteria = joinExp;
else
selectionCriteria = joinExp.and(selectionCriteria);
return selectionCriteria;
This changes the M-M Selection Criteria to "table1 = reltable AND table2 = reltable". Now that this is consistent, using the WHERE clause for my joins in SQL Server is possible.
If you can think of any other problems this change may have, please let me know.
Thanks for the help.
Nate -
Hi
How to use ANSI SQL JOINS (9i) for below query
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL1 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
UNION ALL
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL2 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
UNION ALL
SELECT EMP.EMPNO,EMP_T.TNO,EMP_T.SAL3 FROM EMP,EMP_T WHERE EMP.EMPNO=EMP_T.TNO
EMPNO TNO SAL1
7369 7369 100
7499 7499 1000
7566 7566 400
7782 7782 4000
7369 7369 200
7499 7499 2000
7566 7566 500
7782 7782 5000
7369 7369 300
7499 7499 3000
7566 7566 600
EMPNO TNO SAL1
7782 7782 6000
Regards
MMSELECT EMP.EMPNO,
EMP_T.TNO,
EMP_T.SAL1
FROM EMP
JOIN EMP_T ON ( EMP.EMPNO = EMP_T.TNO )
UNION ALL
SELECT EMP.EMPNO,
EMP_T.TNO,
EMP_T.SAL2
FROM EMP
JOIN EMP_T ON ( EMP.EMPNO = EMP_T.TNO )
UNION ALL
SELECT EMP.EMPNO,
EMP_T.TNO,
EMP_T.SAL3
FROM EMP
JOIN EMP_T ON ( EMP.EMPNO = EMP_T.TNO ) -
OWB 10.2.0.4 ANSI SQL join problem
Hi
Its seams to me, that in OWB 10.2.0.4 there is something broken with ANSI SQL joins and instead of ANSI joins there is used oracle SQL joins only. Maybe someone can point some solutions? I can’t rewrite all mappings with union and other operators. And manually pl/sql editing also would be big problem."Am I correct in assuming you did not code ANSI joins?" -> yes, i am coding Oracle SQL joins and with this option just generating ANSI joins.
With ANSI SQL join you can use OR and IN operands (and code looks more readable).
It is question of performance (so for example 80% of dataset you can join by one column other 15% by second etc ..). So this all can be rewritten also in Split->join->union all, but if you have several such joins, this will be painfully. -
What is the SQL syntax to do Where = "Parameter" ?
I have a menu list linkied to a query. I want the user to select one from the list and pass it to the data source query to return results.
Whats the syntax in the data source SQL to add this in?
My Parameter is called Param1 and I tried:
where xxxx = param1Just a side note, a null parameter in BIP is != null. You have to coalesce the parameter to null. I had to ask a while back to find this little piece of info out.
-
hi..
i'm new for oracle ..
i hav one doubt .. what is the difference between normal join and iso/ansi sql-99 joins...
is any advantage ..
query e.g:
SELECT c.course_name, c.period, e.student_name
FROM course c, enrollment e
WHERE c.course_name = e.course_name(+)
AND c.period = e.period(+);
sql-99 format :
SELECT c.course_name, c.period, e.student_name
FROM enrollment e RIGHT OUTER JOIN course c
ON c.course_name = e.course_name
AND c.period = e.period;Hi
-It is analogous to joining a table, and avoiding the "where" clause
-It allows easier product migration and a reduced learning curve when cross-training
-there is no performance increase compared to the existing syntax.
I hope u got it
Khurram Siddiqui
[email protected]
Maybe you are looking for
-
Windows 8 and 8.1 units loosing connection to printers.
I am having an issue with Windows 8 machines losing connection to Canon Printers. Everything is being run through our server and the issue is only affecting windows 8 and 8.1 machines. They lose connection to the printer (through the server) but the
-
Hi, What is the report/Query should be used to extract the output of invoices which are outstanding as on date. e.g. if I want to see the information of what are the outstanding amount as on 31st March,2010 then which report/query will provide the sa
-
I am facing one problem with Nokia N8. I brought this New Nokia N8 phone from US to India so it is not at all functioning nor responding anything. When I tried to Switch ON this phone it is not responding anything. Can anybody suggest me what should
-
Switching Date and Time?
Hi, I need to switch between Us and European(French) time zones frequently on my mac. Is there a easy way to do this besides preferences. It's quite time consuming. Maybe there is a plug in,third party app, or script? Thanks all.
-
Error code 4005 in itunes restore
Well im on my iphone 4 and it dies then when i charge it it is stuck on the apple logo screen i talked to apple and said to restore it so i when i did it would give me an error code 4005. i run a windows 8.0 toshiba laptop 64 bit. its in ios 7.1. it