I am new in PHP. I have a form having fields from 3 different tables.. I want to search these 3 tables simultaniously for reporting the information...

1st table personal details.
2nd table services offered.
3rd table payment details.

I want to search each and every fields in these tables simultanioulsy...

Please help me...

Can you show us your code ?

Thanks for ur reply nav,,

the code is very big upto 550 lines...

How can i post that all here...

I just want to know there is any trick to search multiple tables...

Please help me...

You can use the join function in mysql.Could you show us what fields are you trying to get in those tables?

You can search multiple tables this way.

	$query1="select * from table1 where column1 like '%$value1%'";
		// fetch the data for query 1
	$query2="select * from table2 where column1 like '%$value2%'";
		// fetch the data for query 2
<form method="post" action="test.php">
<input type="text" name="value1"><br />
<input type="text" name="value2"><br />
<input type="submit" name="submit" value="submit">

There are 2 input fields. Whatever the user enters in 1st input field will search table1 and it searches table2 for 2nd input field.
If this is not what you want, then you have to post your code.

Thanks for ur reply,,

But there are more than 40 fields in these 3 tables......

Is there any way of searching them all in a single query...???


Search 3 tables in a single query ? As ryan_vietnow said, you can use joins to join these 3 tables based on a condition and search for the desired fields.

Here's how'like it goes:

$query="Select * from table1
             LEFT JOIN table2
             LEFT JOIN table3
            WHERE id='1'";

something like that.

well you could make use of the the join as mentioned . Also if you hae MySQL 5 , the use of views could come in handy in the event of intensive usage. It also helps in performance

Thank u very much