I am trying to make a SQL query to select 1 image from each category.
Both images are categories are stored into the database, in difference tables.
Does anyone know a method to do this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This will get you one img per category. But it will not choose which,possibly a random selection…
This code shows the use of a column (is_cat_default) to pick the images. Using this, you define if the image is default in the image table. Removing the
GROUP BYstatement in the last one will pick more than one image par category is there are more than one that hasis_cat_default=1.