•
•
•
•
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
![]() |
•
•
Join Date: May 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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.
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.
•
•
Join Date: May 2005
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
i think you should try T-SQL and loops in them, you can find its documents on http://dev.mysql.com/doc/
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- test mysql query for no results (PHP)
- Double MySQL Query (PHP)
- Python Tuples and Mysql Query (MySQL)
- MySQL query's (MySQL)
- Change MySQL Query Timeout Period (MySQL)
- pagination of mysql query results (PHP)
- SQL search query (PHP)
Other Threads in the MySQL Forum
- Previous Thread: Problem writing to DB can someone take a look at my query string??
- Next Thread: MySQL Question(s)


Linear Mode