Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Like clause queries

Re: Like clause queries

From: Tim X <timx_at_spamto.devnul.com>
Date: 18 Jan 2003 08:49:59 +1100
Message-ID: <87el7bphtk.fsf@tiger.rapttech.com.au>


>>>>> "Sam" == Sam <samevan_at_hotmail.com> writes:

 Sam> I have two queries select T1_Field1 from T1 where T1_Field2 like  Sam> "deptname"

 Sam> select * from T2 where T2_Field2 like T1_Field1

 Sam> Is there anyway to combine these two queries to one?

Not sure exactly what you are after here. However, reading between the lines I'll have a couple of guesses.

  1. You use 'like' - do you really mean like or do you mean '='. Like is used when you want to use wildcard matching (e.g. _ and %). As you don't have any of these in your query, I suspect you might just want =
  2. If what you are trying to do is join the two tables and your column datatypes are the same and you want a result like

        T1.T1_field1, T2.T2_field1, ..., T2_fieldN    

   then what you MIGHT be after is just a join between the two tables    based on T2.Field2 and T1.Field1

select T1.T1_field1, T2.T2_Field1, .., T2.T2_FieldN from T1, T2
where T2.T2_Field2 = T1.T1_Field1
and T1.T1_Field2 = 'depname';

   If you have NULLs in either of your joining fields, you may need to    look into how to do an outer join.

Tim

-- 
Tim Cross
The e-mail address on this message is FALSE (obviously!). My real e-mail is
to a company in Australia called rapttech and my login is tcross - if you 
really need to send mail, you should be able to work it out!
Received on Fri Jan 17 2003 - 15:49:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US