User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 423,874 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,054 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 15351 | Replies: 1
Reply
Join Date: May 2005
Posts: 1
Reputation: OmriA is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
OmriA OmriA is offline Offline
Newbie Poster

Help MySQL query to loop through results distinctly

  #1  
May 28th, 2005
Hey, I am having a really stupid yet annoying problem.

I have a simple database stracture (I'll give an example below) and I want to do a query that will loop through it's elements trying to display the list amount of times each element (trying to make it the most unique it can).


Example for the database:

field 1 | field 2
-------------------
| A_name | A_meow |
-------------------
| A_name | mrgao |
-------------------
| esea | fafas |
-------------------
| A_name | mrewo |
-------------------
| esea | wahod |
-------------------

I want to do a query that will look something like this (it's not real query)
SELECT * FROM `table` LOOP `field 1` LIMIT 4
and the output would be like this:
-------------------
| A_name | A_meow |
-------------------
| esea | fafas |
-------------------
| A_name | mrgao |
-------------------
| esea | wahod |
-------------------

notice how it looped through the field 1 but not the others, that's what I wanna do but I can't figure how!!!!!!!

the closest thing I can do is SELECT DISTINCT(`field 1`), * FROM `table` LIMIT 4
but than I will not recive 4 results like I want, I will recive the amount of distincted field 1 values.

I hope I didn't complex you with the way I asked it but it would really help me if you find a way to do it!

Thanks, Omri.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 5
Reputation: Chagh is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Chagh Chagh is offline Offline
Newbie Poster

Re: MySQL query to loop through results distinctly

  #2  
Jun 1st, 2005
i think you should try T-SQL and loops in them, you can find its documents on http://dev.mysql.com/doc/
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 4:30 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC