473,473 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Grouping mysql result as per arrey

1 New Member
i am using one database in mysql in which it is having a record of source IP(sip), destination IP(dip), source port(sport), destination Port(dport). when doing select query
(select count(sport) as port, sport from IPtable limit 20); the result is as this query states means port sport
3 | 80
5 | 8080
15 | 21
3 | 20
25 | 443
16 | 1234
49 | 2352
15 | 2353

i want to group these ports like

web (80, 8080, 443)
ftp (20, 21)
chat (2352, 2353)
others("rest other ports")

and want output result as

count | port

================

33 | web

18 | ftp

16 | application

64 | others

please help because i want to create pi chart from this output
Feb 23 '15 #1
1 1495
Rabbit
12,516 Recognized Expert Moderator MVP
First of all, your original SQL shouldn't have run, it's missing a group by clause.

Create a table that lists the port number with it's classification. Join that to your table on the port number and use the classification instead of the port number.
Feb 23 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: frizzle | last post by:
Hi there, Short question: Is there any way, to reverse the result of a mysql query? Explanation: If i have eg. 20 records, all with their own id of course, select 5 with limit, and order...
16
by: frizzle | last post by:
Hi there! I'd like to create a function which input is the result of a mySQL query. The output should be exactly the same, only not a mySQL result array, but a 'real' array. So it should also...
9
by: Petr Vileta | last post by:
Hi, I'm new here and excuse me if this question was be here earlier. I have a simple code <html><body> <?php <?php $link = mysql_connect("localhost", "user", "password") or die("Grr: " ....
1
by: automation | last post by:
There is a truncation error of my Web Application using PHP 5.04, MySQL 5.022, and HTML(IE 6.0) whereby the MySQL Result Set is being truncated on the HTML page, even though the CSS Div Page Height...
4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
0
by: Marcel Molenaar | last post by:
Anyone ever experienced this problem. When i pass a mysql result to the constructor of a class and use that resultset inside that class the original resultset outside the class gets affected...
4
by: fisherd | last post by:
When i run this code, i keep getting this message; Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\checklogin.php on line 26 i use this code to...
0
Atli
by: Atli | last post by:
What to discuss: What is a "MySQL resource". What causes the error. How to fix it. Common Newbie Pitfalls This article is the second installment in a series of (hopefully) many, following...
1
ilya Kraft
by: ilya Kraft | last post by:
Hello, Right, I installed this new feature on my web, but I get 5 following errors and I don't see the problem, I tried asking the person who made a tutorial for this feature, but he has not...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.