I want to search in two tables. Tried this but didn't worked. I'm getting error "Unkown Column...."
HTML:
<form method="post"
<input type="text" name="search_keyword">
<input type="submit" name="button_search">
</form>
MYSQL SELECT AND PHP:
if(isset($_POST['button_search']))
{
$search_keyword = $_POST['search_keyword'];
$select = mysql_query("SELECT * from table_1 WHERE match(name_1) against ($search_keyword)
union all SELECT * from table_2 WHERE match(name_2) against ($search_keyword)");
while($row = mysql_fetch_array($select))
{
echo $row['question'];
echo $row['category_name'];
}
}
TABLES:
For example:
Table 1:
table name: table_1
Values (table 1):
+-------+-------------+
| id_1 | name_1 |
+-------+-------------+
| 1 | Phinoy |
| 2 | Go |
+-------+-------------+
Table 2:
table name: table_2
Values:
+-------+-------------+
| id_2 | name_2 |
+-------+-------------+
| 1 | Gi |
| 2 | Phinas |
+-------+-------------+
If I search "P" or "Ph" , it will show the values "Phinoy and Phinas".