473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Retrieving The Most Commonly Used Field Value In a Table

I've got a table which is used for storing votes, each row has a field with
a reference to the user who's been voted for and i'd like to simply get the
user ref with the most votes,or if tied, return both of them. I cant use
subqueries as it's a mysql 4.0 server, any ideas on how i could do it
(without retrieving all the nominees then doing select count(*) for all of
them then sorting them externaly).

thanks,
peter

Jul 19 '05 #1
2 1966
Perhaps use a statement like 'Insert into temptable select user_ref,
count(*) from vote, user .... having count(*) > n'. Replace n per your
requirement. Then select user_ref from temptable that has the maximum count.

"peter" <pe******************@hotmail.com> wrote in message
news:v1***************@newsfep4-winn.server.ntli.net...
I've got a table which is used for storing votes, each row has a field with a reference to the user who's been voted for and i'd like to simply get the user ref with the most votes,or if tied, return both of them. I cant use
subqueries as it's a mysql 4.0 server, any ideas on how i could do it
(without retrieving all the nominees then doing select count(*) for all of
them then sorting them externaly).

thanks,
peter

Jul 19 '05 #2
Perhaps use a statement like 'Insert into temptable select user_ref,
count(*) from vote, user .... having count(*) > n'. Replace n per your
requirement. Then select user_ref from temptable that has the maximum count.

"peter" <pe******************@hotmail.com> wrote in message
news:v1***************@newsfep4-winn.server.ntli.net...
I've got a table which is used for storing votes, each row has a field with a reference to the user who's been voted for and i'd like to simply get the user ref with the most votes,or if tied, return both of them. I cant use
subqueries as it's a mysql 4.0 server, any ideas on how i could do it
(without retrieving all the nominees then doing select count(*) for all of
them then sorting them externaly).

thanks,
peter

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: sebmil | last post by:
Hello, I have a table with two columns, created with : CREATE TABLE test ( id serial primary key, name text ) ; To populate the table i use : INSERT INTO test(name) values('test1'); so the...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
1
by: Olaf Rabbachin | last post by:
Hi folks, I'm looking for a way of retrieving the default-value of a table's field within an Access 2003 MDB. Any hints on how to accomplish this from ASP.Net? Thanks, Olaf -- My .02:...
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
2
by: 4Ankit | last post by:
hello all, i am having some difficulty retrieving information from my form. I want to add content in my table but the content i want to add to the table is what the user inputs in my form. ...
9
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
3
ADezii
by: ADezii | last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method...
2
by: falroc | last post by:
I have a data base that is used for billing. I have a form called a report selector form. Below is the code used to create the report from the user inputs on the form. What I want to do is add a...
6
by: solom190 | last post by:
Okay this is the situation I have two forms and they have a 1:M relationship. I don't have enough space screen-wise to do a traditional "drag form to form" to create a subform so what I did was...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.