Re: rewriting query without using UNION
I don't see why would query with multiple unions necessarily degrade performance, but here is another way for writing your query: select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and ( e.name='JOSE' or d.deptno=50) / That would be a union of all employees from the department with deptno=50 plus the ones called JOSE. On 10/29/2003 12:54:26 PM, Linda Wang wrote: Hi, I wonder if there's a better way of writing the query below. Basically, I would like to return employee records where employee name='JOSE' + all employees in deptno=50. My query can have multiple 'OR' criterias where the next criteria maybe returning all employees with salary6 in addition to the above two criterias. Building the query with multiple UNIONs will definitely degrade the query performance. Is there a better way of rewriting the query? Thanks! linda select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and e.name='JOSE' union select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and d.deptno=50; _ Want to check if your PC is virus-infected? Get a FREE computer virus scan online from McAfee. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Linda Wang INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Mladen Gogala Oracle DBA Note: This message is for the named person's use only. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. Wang Trading LLC and any of its subsidiaries each reserve the right to monitor all e-mail communications through its networks. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity. -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Mladen Gogala INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
Re: rewriting query without using UNION
from basic set theory: union = OR intersect = AND select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and e.name='JOSE' or d.deptno = 50; From: Linda Wang [EMAIL PROTECTED] Date: 2003/10/29 Wed PM 12:54:26 EST To: Multiple recipients of list ORACLE-L [EMAIL PROTECTED] Subject: rewriting query without using UNION Hi, I wonder if there's a better way of writing the query below. Basically, I would like to return employee records where employee name='JOSE' + all employees in deptno=50. My query can have multiple 'OR' criterias where the next criteria maybe returning all employees with salary6 in addition to the above two criterias. Building the query with multiple UNIONs will definitely degrade the query performance. Is there a better way of rewriting the query? Thanks! linda select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and e.name='JOSE' union select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and d.deptno=50; _ Want to check if your PC is virus-infected? Get a FREE computer virus scan online from McAfee. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Linda Wang INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: [EMAIL PROTECTED] INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
RE: rewriting query without using UNION
select e.ID, e.NAME, d.DEPTNAME from EMP e, DEPT d where e.DEPTNO = d.DEPTNO and (e.NAME = 'JOSE' or d.DEPTNO = 50); -Original Message- Sent: Wednesday, October 29, 2003 12:54 PM To: Multiple recipients of list ORACLE-L Hi, I wonder if there's a better way of writing the query below. Basically, I would like to return employee records where employee name='JOSE' + all employees in deptno=50. My query can have multiple 'OR' criterias where the next criteria maybe returning all employees with salary6 in addition to the above two criterias. Building the query with multiple UNIONs will definitely degrade the query performance. Is there a better way of rewriting the query? Thanks! linda select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and e.name='JOSE' union select e.id, e.name, d.deptname from emp e, dept d where e.deptno=d.deptno and d.deptno=50; _ Want to check if your PC is virus-infected? Get a FREE computer virus scan online from McAfee. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963 -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Linda Wang INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Rudy Zung INET: [EMAIL PROTECTED] Fat City Network Services-- 858-538-5051 http://www.fatcity.com San Diego, California-- Mailing list and web hosting services - To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).