Click here to Skip to main content
15,883,796 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
is that possible to fetch data from 2 different tables without join ??

for ex: i have 2 tables table1 and table2 and both have name field. now i want to fetch complete record of both table.

i use following query but its not work

PHP
$fetch = mysql_query("select * from table1,table2");
while ($row = mysql_fetch_array($fetch))
{
  echo $row['name'].table1;
echo $row['name'].table2;

}


but its not work :(... can u plz help me.
Posted
Comments
Wessel Beulink 12-Nov-15 10:17am    
Fetch them seperated from each other with 2 functions instead of 1??
Or use a join. Why whould you do this... not the way to go.

1 solution

You can do :
PHP
$fetch = mysql_query("select name from table1 union all select name from table2");
 
Share this answer
 
Comments
Mohibur Rashid 13-Nov-15 2:27am    
nice

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900