Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Selecting information from one db, prices from another


Elric99 - 11:34 am on Feb 13, 2013 (gmt 0)


Hello

My situation is I have one database with product information, another with prices. I need to get info from the first and prices from the second. This code seems to work, but I'd like to know if it's a good idea to add in the 'AND's on the JOIN in this way:

SELECT i.productId, i.id, p.wasPrice, p.thisPrice FROM product_info i
LEFT JOIN product_prices p
ON i.productId = p.productId AND i.dealDate = p.dealDate AND i.wasPrice = p.wasPrice
WHERE i.dealDate = '2013-08-16'
AND i.productId = 'NB5726'
GROUP BY i.id

Thanks!

Tom


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4545264.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com