Okay, so no one here have sufficient knowledge on my previous question. Hopefully someone can help with this one. I want to search 3 tables, all with the same fields. My users will search only one field. This is what code I have, but it does not work. <?php $link = mysql_connect ("localhost", "xxxx","xxxx") or die (mysql_error()); mysql_select_db ("xxxxx",$link); $term = $_POST['term']; { $sql = mysql_query("SELECT * FROM 'data2','data3' WHERE ID_NUMBER like '%$term%'"); $coloum = mysql_fetch_array($sql) ?> Code (markup): Any suggestions?
tip : use ` instead ' <?php $link = mysql_connect ("localhost", "xxxx","xxxx") or die (mysql_error()); mysql_select_db ("xxxxx",$link); $term = $_POST['term']; { $sql = mysql_query("SELECT * FROM `data2`,`data3` WHERE ID_NUMBER like '%$term%'"); $coloum = mysql_fetch_array($sql) ?>
my suggestion is you should FULL JOIN all 3 tables, the key is the same field <?php $link = mysql_connect ("localhost", "xxxx","xxxx") or die (mysql_error()); mysql_select_db ("xxxxx",$link); $term = $_POST['term']; $query = " SELECT * FROM data1 FULL JOIN data2 ON data1.ID_NUMBER = data2.ID_NUMBER FULL JOIN data3 ON data1.ID_NUMBER = data3.ID_NUMBER WHERE COALESCE(data1.ID_NUMBER, data2.ID_NUMBER,data3.ID_NUMBER) LIKE '%term%' "; $sql = mysql_query($query); $coloum = mysql_fetch_array($sql) ?> Code (markup): okay hope it's work.
Thanks anxggxun, but I get an Internal 500 error when trying to do this, crivion, I am not sure what you are telling me to do. Thanks in any event,
it works when i was try to do something like that, hmm i never thought it could make a http error, i'll try to find its mistakes...
Hi anxggxun I have figured out why the 500 error happens. It is fixed, but no results are displayed when I make use of the ample above.