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:
i would like it to also search in the table "proyectos_detalle" and in cell title_proyectos
$not_query_raw = "select * from contenidos where title_contenidos like '%" . $_GET['q'] . "%' and id_lang='".$id_lang."' order by order_contenidos,id_contenidos " ;
i would like it to also search in the table "proyectos_detalle" and in cell title_proyectos
u could use inner join on the field you want to search
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_conten idos " ;
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.
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.
ASKER
i was referring for a example code for my script
ASKER
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!
ASKER
the search should look in 2 tables and 2 colums
1. TABLE= contenidos COLUM = title_contenidos
2. TABLE= proyectos_detalle COLUM = title_proyectos
1. TABLE= contenidos COLUM = title_contenidos
2. TABLE= proyectos_detalle COLUM = title_proyectos
$raw = "select * from contenidos,proyectos_detal le where contenidos.title_contenido s = proyectos_detalle.title_pr oyectos and contenidos.title_contenido s like '%" . $_GET['q'] . "%' and id_lang='".$id_lang."' order by order_contenidos,id_conten idos " ;
if still can't works,try to echo it
if still can't works,try to echo it
ASKER
1052 - Column 'id_lang' in where clause is ambiguous
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.