NeoAshura
asked on
PHP Query, OUTPUT
Hi Experts,
Ive got a query that returns results from a database but does not return all entries under the "last_spoken_to" field.. which is in the notes table..
the current query i have is as follows:
$sql = "select * from customer left join notes on customer.customer_name = notes.customer_name WHERE customer.customer_name = '" . $val . "'";
I have tried the following:
$sql = "select * from customer left join notes on customer.customer_name = notes.customer_name AND customer.customer_name = last_spoke_to.customer_nam e WHERE customer.customer_name = '" . $val . "'";
but that does not work, it returns an error, What i have got is attached in the picture, And i need it to produce the same output as the notes category.
Many thanks
AS you can see from the picture Notes repeats but last spoke to does not how would i get it to repeat like the notes? as i stated ive tried the above query but that did not work.
picture5.jpg
Ive got a query that returns results from a database but does not return all entries under the "last_spoken_to" field.. which is in the notes table..
the current query i have is as follows:
$sql = "select * from customer left join notes on customer.customer_name = notes.customer_name WHERE customer.customer_name = '" . $val . "'";
I have tried the following:
$sql = "select * from customer left join notes on customer.customer_name = notes.customer_name AND customer.customer_name = last_spoke_to.customer_nam
but that does not work, it returns an error, What i have got is attached in the picture, And i need it to produce the same output as the notes category.
Many thanks
AS you can see from the picture Notes repeats but last spoke to does not how would i get it to repeat like the notes? as i stated ive tried the above query but that did not work.
picture5.jpg
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@MunterMan:
that was my idea as well; but does it make sense selecting all customers who have talked to themselves?????
That's why I said that knowledge about the tables and the fields within those tables is necessary to answer NeoAshura's question.
that was my idea as well; but does it make sense selecting all customers who have talked to themselves?????
That's why I said that knowledge about the tables and the fields within those tables is necessary to answer NeoAshura's question.
ASKER
ok guys ive solved it but i appricate your input so points will be awrded equally. Ive outputed what i needed using the following:
$sql = "
SELECT *
FROM customer
LEFT JOIN notes
ON customer.customer_name = notes.customer_name
WHERE customer.customer_name = '" . $val . "'";
It is a notes page based on each customer, These notes needed to be logged.. it now looks as follows which is what i needed.
picture6.jpg
$sql = "
SELECT *
FROM customer
LEFT JOIN notes
ON customer.customer_name = notes.customer_name
WHERE customer.customer_name = '" . $val . "'";
It is a notes page based on each customer, These notes needed to be logged.. it now looks as follows which is what i needed.
picture6.jpg
ASKER
Both notes is a table and contains "notes" and "last_spoke_to"
where customer is another table and customer_name is a field in that table which also exsits in the notes table as a referance for the notes and last spoke to. does that make sense?