List:General Discussion« Previous MessageNext Message »
From:Highviews Date:July 7 2009 12:57am
Subject:Using RANDOM before GROUP BY technique returned only a single column
View as plain text  
I am using a technique described here at:,227102,227102#msg-227102

To make results Random before applying the GROUP BY method.
The query to my table structure is this:

SELECT r.physicians_id,
(SELECT FROM physicians_images r1 WHERE
(r.physicians_id=r1.physicians_id AND procedures LIKE '%8%' AND category =
'beforeafter' AND publish = 1) ORDER BY rand() LIMIT 1) AS 'id' FROM
physicians_images r
GROUP BY r.physicians_id ;

I have the following columns:
id, physicians_id, imageName, imagePath, title, imageDetails, DateTime,
publish, Date, ip, category, site, patientName and procedures

The query is working well, but it only returned the ID, not the whole row.
How can i get the complete rows in results?

I tried using * but its returning with the following error:
#1241 - Operand should contain 1 column(s)

Any help??



Using RANDOM before GROUP BY technique returned only a single columnHighviews7 Jul