![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
| |||
| 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 |
| |||
| "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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |