I have a query that looks like this:
SELECT p.prodname, p.prodcode, o.vovalue, p.productid, i.imageprodid, c.vcstock, p.prodcatids, t.catname
FROM isc_products p
LEFT OUTER JOIN isc_product_variation_combinations c ON c.vcproductid = p.productid
LEFT OUTER JOIN isc_product_variations v ON v.variationid = c.vcvariationid
LEFT OUTER JOIN isc_product_variation_options o ON o.voptionid = c.vcoptionids
LEFT OUTER JOIN isc_product_images i ON i.imageprodid = p.productid
LEFT OUTER JOIN isc_categories t ON t.categoryid = p.prodcatids
WHERE c.vcstock >1
AND i.imageprodid IS NULL
ORDER BY ca.catname
I am trying to retrieve the category name (t.catname) in a column.
It’s returning a NULL value because of the Join of t.categoryid = p.prodcatids.
p.prodcatids is text (utf8_general) and t.categoryid is int(11).
How can I convert (cast?) p.prodcatids as int11 so that it will join on t.categoryid?
if this is in mysql – did you check the convert and cast functions ? http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_cast