I have this query that return to me all rows for one user
$strSQL = "SELECT * FROM customer , bills , vouchers
WHERE
bills.bills_CustomerName = customer.customer_Name and
vouchers.vouchers_CustomerName = customer.customer_Name and
bills.bills_CustomerName like '%".$_POST["MyName"]."%'
";
I have the problem that one row are repeated 2 times, the customer table is related to the bills table and to the vouchers table on one FK column.
bills table :
bills_ID - bills_CustomerName - bills_Total
customer table :
customer_ID - customer_Name - customer_Tell
vouchers table :
vouchers_ID - vouchers_CustomerName - vouchers_Total
we are get
Name Total Tell
kam johin 100 0444444444
kam johin 100 0444444444
mak pop 200 0588888888
mak pop 200 0588888888
If customer to bill is one-to-many and customer to voucher is also one-to-many then you have what is sometimes known as a “chasm trap”, and you will have to aggregate child values from bill and voucher before joining to customer.
Or perhaps your data model should be more like:- Customer->Bill->Voucher, in which case you need to include in the voucher table a foreign key to the Bill to which the voucher relates.
BTW you could probably use some surrogate key for customer – what happens when two different customers have the same name?