
Originally Posted by
jc_gmk
Thanks,
the query i'm using is:
$sql = "SELECT t1.NAME, t2.PRICE FROM product AS t1 LEFT JOIN productprogram AS t2 ON t1.PRODUCTID = t2.PRODUCTID WHERE PRODUCTID = '$id'";
The error message is:
Notice: Query failed: Column 'PRODUCTID' in where clause is ambiguous SQL: SELECT t1.NAME, t2.PRICE FROM product AS t1 LEFT JOIN productprogram AS t2 ON t1.PRODUCTID = t2.PRODUCTID WHERE PRODUCTID = 'Y6UJ9A00000A' in K:\My Documents\Websites\...\mysql.class.php on line 109
oops sorry, I forgot that you need to add the table in the where since its referencing the same in both. but t1 and t2 are also really not helping at all, so try this instead
PHP Code:
$sql = "SELECT p.NAME, pp.PRICE FROM product AS p LEFT JOIN productprogram AS pp ON p.PRODUCTID = pp.PRODUCTID WHERE p.PRODUCTID = 'Y6UJ9A00000A';

Originally Posted by
jc_gmk
Also, it seems to me that using a 'JOIN' creates a temporary table?
As both my tables have over 130,000 entries do you think there will be any performance issues?
yes it will create a temporary table, there are a bunch of different types of joins that you could use, however for this instance I believe that a LEFT JOIN would be the easiest. it is grabbing the records from both tables and putting them into the same table side by side, then it grabs the fields you requested. this is actually the fastest option you have, so if you have any performance issues it will not be because of the query as you have described.
sorry for the confusion and let us know if you need any more help
Bookmarks