Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Like clause queries
DA Morgan <damorgan_at_exesolutions.com> wrote in
news:3E284FEB.A787B50E_at_exesolutions.com:
> Sam wrote:
>
>> I have two queries >> >> select T1_Field1 from T1 where T1_Field2 like "deptname" >> >> select * from T2 where T2_Field2 like T1_Field1 >> >> Is there anyway to combine these two queries to one?
Unless Sam wants to dummy up query numero uno to return the same number of columns as query number two:
select T1_Field1, NULL, NULL ...
UNION ... select * from T2
This means that the type of the first column in the second select needs to be the same type ... err, ya know what, this just 'feels' wrong. Are the two queries related? If they are, you can go with what I'm suggestioning. Also, for safety sake, I'd not use '*', I'd enumerate all the columns. Of course the latter will break if the table is modified so perhaps using '*' is fine. :)
-- Pablo Sanchez, High-Performance Database Engineering http://www.hpdbe.comReceived on Fri Jan 17 2003 - 14:00:46 CST
![]() |
![]() |