View Single Post
  #2 (permalink)  
Old 03-17-2006, 04:48 AM
no.mail.pls
 
Posts: n/a
Default Re: Retrieve fields with similar values from 2 tables?

"Bill Karwin" <bill@karwin.com> wrote in message
news:dvdg9s02pk@enews3.newsguy.com...
> "no.mail.pls" <no.mail@st.peters> wrote in message
> news:441a4132$0$15790$14726298@news.sunsite.dk...
>> I tried to use
>> "SELECT * FROM $table1 as o , $table2 as p WHERE o.name like '%p.name%'";

>
> This is close, but putting p.name inside the quotes make it use the string
> 'p.name', instead of the value of that field. Try the following:
>
> SELECT * FROM $table1 as o , $table2 as p
> WHERE o.name LIKE CONCAT('%', p.name, '%');
>
> Regards,
> Bill K.


Thanks Bill, but it still doesn't work.

The command
SELECT * FROM $table1 as o , $table2 as p WHERE o.name LIKE CONCAT('%',
p.name, '%');
will retrieve exact matches only.

The command
"SELECT * FROM $table1 as o , $table2 as p WHERE o.name like '%p.name%'";
will retrieve nothing at all.

Any advice will be appreciated.

TIA



Reply With Quote