Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-17-2006, 03:55 AM
no.mail.pls
 
Posts: n/a
Default Retrieve fields with similar values from 2 tables?

Hi,

How do i retreive fields with similar values from 2 tables?

I tried to use
"SELECT * FROM $table1 as o , $table2 as p WHERE o.name like '%p.name%'";
but it doesn't retrieve similar names from the 2 tables.

However,
"SELECT * FROM $table1 as o , $table2 as p WHERE o.name like p.name";
will retrieve only names that match exactly, but this is not what i want.

Any advice will be appreciated.

TIA




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:12 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.