F
F
FEAR932014-04-14 20:04:30
SQL
FEAR93, 2014-04-14 20:04:30

How to select only one image from a category?

Good day. Help solve the problem.
It costs Joomla with the JoomGallery module. You need to change the gallery search so that only one picture that matches the query is displayed from one category.
That is, let's say there are five categories, they have two pictures with a name in which the word "train" occurs, as a result of the output there should be not ten pictures, but five, one from each category.
You can choose them by rating or upload date, no difference.
The search query now looks like this

SQL=SELECT a.*, ROUND(LEAST(IF(imgvotes > 0, a.imgvotesum/a.imgvotes, 0.0), 5), 2) AS rating, u.username, ca.cid, ca.name AS name,( SELECT COUNT(*) FROM mnpx3_joomgallery_comments WHERE cmtpic = a.id AND published = 1 AND approved = 1) As comments FROM mnpx3_joomgallery AS a1 INNER JOIN mnpx3_joomgallery_catg AS ca ON a.catid = ca.cid LEFT JOIN mnpx3_users AS u ON a.owner = u.id WHERE (u.username LIKE '%баба%' OR a.imgtitle LIKE '%баба%' OR LOWER(a.imgtext) LIKE '%баба%') AND a.published = 1 AND a.approved = 1 AND a.access IN (1,1,5) AND ca.published = 1 AND ca.access IN (1,1,5) AND ca.cid IN (4,3,2) AND a.hidden = 0 AND ca.hidden = 0 AND ca.in_hidden = 0 AND ca.exclude_search = 0 GROUP BY a.id ORDER BY a.id DESC

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
1001001 111, 2014-04-15
@IgorO2

Organize by category

F
FEAR93, 2014-05-02
@FEAR93

Could you help with an example?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question