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: Sam <samevan_at_hotmail.com>
Date: 18 Jan 2003 05:44:31 -0800
Message-ID: <35a7dd54.0301180544.7fbbc47e@posting.google.com>


Tim X <timx_at_spamto.devnul.com> wrote in message news:<87el7bphtk.fsf_at_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

Thank you for reply

Have to use LIKE because the field is in a long string. By the way it should be T1.T1_Field2 = '%depname%';

The question here is how to join two queries with LIKE clause

subqueries??? any ideas?

Sam Received on Sat Jan 18 2003 - 07:44:31 CST

Original text of this message

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