you have only asked it to select the name and the price, if you need something else selected you need to add them to the selectSELECT p.NAME, pp.PRICE FROM
you have only asked it to select the name and the price, if you need something else selected you need to add them to the selectSELECT p.NAME, pp.PRICE FROM
"SELECT p.NAME, pp.PRICE FROM product AS p LEFT JOIN productprogram AS pp ON p.PRODUCTID = pp.PRODUCTID WHERE p.PRODUCTID = '$id'"
it seems there WHERE has no effect on which entry it selects
Whether I do the above or change it to:
"SELECT p.NAME, p.PRODUCTID, pp.PRICE FROM product AS p LEFT JOIN productprogram AS pp ON p.PRODUCTID = pp.PRODUCTID WHERE p.PRODUCTID = '$id'"
It still only selects the first record in the table.
do you have some example output? or a site that can link us to an example?
also print out the exact query that it is generating. that may help in understanding why its not returning the full result set
the other thing would be to go into your SQL manager, and try to run the query and see what is returned.
if there are any errors produced please post those as well.
another thing to test is to do a query like
and plug in some actual values for the $id. that query should return every field that describe each record (data entry)Code:SELECT p.*, pp.* FROM product AS p LEFT JOIN productprogram AS pp ON p.PRODUCTID = pp.PRODUCTID WHERE p.PRODUCTID = '$id';
Last edited by boogyman; 10-18-2007 at 01:37 PM.
I have finally cracked it!
Thanks very much for all your help!
![]()
congrats, what ended up being the problem?
not entirely sure but I did as you suggested and ran the query through my SQL manager, that didn't work but I was able to change the code easily from there.
ended up changing it to this:
$sql = "SELECT product.NAME, productprogram.PRICE FROM product LEFT JOIN productprogram ON product.PRODUCTID = productprogram.PRODUCTID WHERE product.PRODUCTID = '$id'";
I don't know if it's better to have aliases or not but once I used this code everything worked perfectly!
Thanks again for your help! Much appriciated.
![]()
Bookmarks