I have the following MySQL queries:
Query #1:
SELECT imgURL, imgTitle, FROM images
Query #2:
SELECT DISTINCT imgFamily FROM images
Query #3:
SELECT DISTINCT imgClass FROM images
I'm wondering if it is possible to combine them into one query? In other words, SELECT imgURL, imgTitle, DISTINCT imgFamily, and DISTINCT imgClass.
When I attempted to do it as above (without the and), it failed. Any suggestions?
The result I get is the following: MySql ErrorYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT imgFamily FROM images
The result I expect is to not have an error, and have rows returned.
DISTINCTis per result row, not per individual result field. Are you trying to return the entire list of images along with the entire list of imgFamilies and entire list of imgClasses? That doesn't make sense, as they are different pieces of information and must thus be separate queries.DISTINCTkeywords except for one immediately afterSELECT(optional, obviously). However, as explained above, I don't think those results would yield what you're actually looking for.SELECT imgURL, imgTitle, imgFamily, imgClass ..., that would give you the family and class that each particular image is in. If 30 of the images had the same family, then those 30 result rows would all have the same value in family. I don't think that's what you want, right?