Solved

Multiple tables search

Posted on 2010-09-23
11
397 Views
Last Modified: 2012-05-10
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
Comment
Question by:jd_18286
  • 5
  • 3
  • 3
11 Comments
 
LVL 3

Expert Comment

by:Progressed
ID: 33745425
u could use inner join on the field you want to search
0
 

Author Comment

by:jd_18286
ID: 33745451
can i have an example code i have no idea how to do it
0
 
LVL 3

Expert Comment

by:Progressed
ID: 33745514
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 1

Expert Comment

by:lovelybabe
ID: 33745543
$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
 

Author Comment

by:jd_18286
ID: 33745580
i was referring for a example code for my script
0
 

Author Comment

by:jd_18286
ID: 33745611
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
 
LVL 3

Expert Comment

by:Progressed
ID: 33745614
look at the comment of lovelybabe... that should do it!
0
 

Author Comment

by:jd_18286
ID: 33745828
the search should look in 2 tables and 2 colums

1. TABLE= contenidos COLUM = title_contenidos
2. TABLE= proyectos_detalle COLUM = title_proyectos
0
 
LVL 1

Expert Comment

by:lovelybabe
ID: 33745917
$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
 

Author Comment

by:jd_18286
ID: 33745996
1052 - Column 'id_lang' in where clause is ambiguous
0
 
LVL 1

Accepted Solution

by:
lovelybabe earned 500 total points
ID: 33746113
u need add table name for id_lang,
contenidos.id_lang or proyectos_detalle.id_lang
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
remote mysql 8 36
Change a button after e-mail 4 19
Generate PDF's using TCPDF - Initial Set Up 9 29
Modify Filter to cause a field to be not Required 3 27
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question