• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 403
  • Last Modified:

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
0
jd_18286
Asked:
jd_18286
  • 5
  • 3
  • 3
1 Solution
 
ProgressedCommented:
u could use inner join on the field you want to search
0
 
jd_18286Author Commented:
can i have an example code i have no idea how to do it
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
lovelybabeCommented:
$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.
0
 
jd_18286Author Commented:
i was referring for a example code for my script
0
 
jd_18286Author Commented:
but i would like the search to take place also in title_proyectos like '%" . $_GET['q'] . "%'  not only in title_contenidos like '%" . $_GET['q'] . "%'
0
 
ProgressedCommented:
look at the comment of lovelybabe... that should do it!
0
 
jd_18286Author Commented:
the search should look in 2 tables and 2 colums

1. TABLE= contenidos COLUM = title_contenidos
2. TABLE= proyectos_detalle COLUM = title_proyectos
0
 
lovelybabeCommented:
$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
0
 
jd_18286Author Commented:
1052 - Column 'id_lang' in where clause is ambiguous
0
 
lovelybabeCommented:
u need add table name for id_lang,
contenidos.id_lang or proyectos_detalle.id_lang
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 5
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now