I want to get two tables in one select query without inner join can i do that?
if(isset($_POST['search']))
{ $name=$_POST['searchtxt'];
$result = mysql_query("SELECT * FROM `product_tb_men` WHERE `name` LIKE '%".$name."%'");
}
this is not the complete code and the second table name is product_tb_women..
You can use UNION
this way
if(isset($_POST['search']))
{
$name=$_POST['searchtxt'];
$query = "SELECT * FROM `product_tb_men` WHERE `name` LIKE '%".$name."%'"
." UNION "
."SELECT * FROM `product_tb_women` WHERE `name` LIKE '%".$name."%'";
$result = mysql_query($query);
}
You do need to consider the usage of mysql_*
functions and sanitize the value of name to avoid SQL injection
Use if statement... If(first query) {do } else if (second query ) {do}
$result = mysql_query("SELECT *.pm, *.pw FROM product_tb_men
pm, product_tb_women pw WHERE pm.name
LIKE '%".$name."%'" or pw.name LIKE '%".$name."%'");