coxdabd — 2011-02-13T07:16:49-05:00 — #1
Hi all, I have a query which is selecting DISTINCT sizes from my database only it doesn't seem to be returning DISTINCT sizes. My query is below along with a screen grab of what the query is returning. Appreciate any help
SELECT DISTINCT sizes FROM products AS p LEFT JOIN
products_to_section as o ON p.id=o.prod_id WHERE o.section_name='all-accessories'
r937 — 2011-02-13T07:34:39-05:00 — #2
there are likely some extraneous spaces or other non-printable characters
do a dump of those rows and show us the INSERT statements
r937 — 2011-02-13T07:36:57-05:00 — #3
by the way, you want to use INNER JOIN, not LEFT OUTER JOIN
by using LEFT OUTER JOIN, you're saying that there might be rows in products_to_section that have a prod_id for a product that doesn't exist
coxdabd — 2011-02-13T08:02:57-05:00 — #4
Hey bud, you were absolutely correct, there was a few nasty spaces on the sizes, very annoying. Gone through them all now and removed any spaces and all is working perfectly. I'll be sure to use the PHP trim function next time to strip any spaces.
Right ok, I'll take a look into using INNER JOIN. Thanks for the pointer