Link to home
Start Free TrialLog in
Avatar of jd_18286
jd_18286

asked on

Multiple tables search

Hi, i have this code that makes a search in a table called "contenidos" in the cell "title_contenidos" it works fine but i would like to make it search also in another table and cell:

$not_query_raw = "select * from  contenidos where  title_contenidos like '%" . $_GET['q'] . "%' and id_lang='".$id_lang."'  order by order_contenidos,id_contenidos "    ;

Open in new window


i would like it to also search in the table "proyectos_detalle" and in cell title_proyectos
Avatar of Progressed
Progressed

u could use inner join on the field you want to search
Avatar of jd_18286

ASKER

can i have an example code i have no idea how to do it
$raw = "select * from contenidos,contenidos2 where contenidos.id = contenidos2.id and title_contenidos like '%" . $_GET['q'] . "%' and id_lang='".$id_lang."'  order by order_contenidos,id_contenidos "  ;

contenidos2 is the another table
contenidos.id is the example of column name in contenidos,same as in contenidos2.
the value of id is same in two tables.
i was referring for a example code for my script
but i would like the search to take place also in title_proyectos like '%" . $_GET['q'] . "%'  not only in title_contenidos like '%" . $_GET['q'] . "%'
look at the comment of lovelybabe... that should do it!
the search should look in 2 tables and 2 colums

1. TABLE= contenidos COLUM = title_contenidos
2. TABLE= proyectos_detalle COLUM = title_proyectos
$raw = "select * from contenidos,proyectos_detalle where contenidos.title_contenidos = proyectos_detalle.title_proyectos and contenidos.title_contenidos like '%" . $_GET['q'] . "%' and id_lang='".$id_lang."'  order by order_contenidos,id_contenidos "  ;
if still can't works,try to echo it
1052 - Column 'id_lang' in where clause is ambiguous
ASKER CERTIFIED SOLUTION
Avatar of lovelybabe
lovelybabe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial