I have this SQL Query in PHP:
$sql="SELECT * from customer c JOIN commsone_phonelines b where b.phone_number LIKE '%".$_POST["search"]."%' AND ";
$sql.="c.company like '%".$_POST["search"]."%' OR ";
$sql.="c.forename like '%".$_POST["search"]."%' OR ";
$sql.="c.surname like '%".$_POST["search"]."%' OR ";
$sql.="CONCAT_WS(' ',c.forename, c.surname) LIKE '%".$_POST["search"]."%' OR ";
$sql.="c.phone like '%".$_POST["search"]."%' OR ";
$sql.="c.accountnumber like '%".$_POST["search"]."%' OR ";
$sql.="c.customerid like '%".$_POST["search"]."%' OR ";
$sql.="c.voip_account like '%".$_POST["search"]."%' OR ";
$sql.="REPLACE(c.postcode,' ','') LIKE '%".$_POST["search"]."%' OR ";
$sql.="REPLACE(c.postcode,'',' ') LIKE '%".$_POST["search"]."%' OR ";
$sql.="c.postcode LIKE '%".str_replace(' ','',$_POST["search"])."%' ";
$sql.=" AND c.resellerid = '' ORDER BY company ASC";
i am basically, trying to select from two different tables and i need to echo information only from the customer table.
If something is found in the commsone_phonelines table, it should link commsone_phonelines.customer_seq = customer.sequence
UPDATE:
I have just run this Query:
SELECT c.* from customer c INNER JOIN commsone_phonelines b ON c.sequence = b.client_seq where b.phone_number LIKE '%boat%' OR c.company like '%boat%'
it is returning rows from the customer table which is correct, however it shows the same row 5 times