hi i wonder if there's a way to select a most occuring element from a table with one select statement? if not, what's the most efficient way you think to do it?
here's my problem. i have a table whose structure is like this
CREATE TABLE posts (
fid smallint(6) NOT NULL default '0',
tid smallint(6) NOT NULL default '0',
pid int(10) NOT NULL auto_increment,
author varchar(40) NOT NULL default '',
message text NOT NULL,
subject varchar(100) NOT NULL default '',
dateline bigint(30) NOT NULL default '0',
icon varchar(50) default NULL,
usesig varchar(15) NOT NULL default '',
useip varchar(40) NOT NULL default '',
bbcodeoff varchar(15) NOT NULL default '',
smileyoff varchar(15) NOT NULL default '',
PRIMARY KEY (pid),
KEY fid (fid),
KEY tid (tid),
KEY dateline (dateline)
) TYPE=MyISAM;
i wish to select the most occuring fid for a specific author. something like
SELECT fid FROM posts FROM author='blah' ORDER BY count(fid) DESC LIMIT 1
i know the above is NOT WORKING.
tips are welcome! thanks!