Solved

bash MySQL result into array

Posted on 2013-06-07
2
616 Views
Last Modified: 2013-07-23
I have a script that runs every 15 minutes which looks for phone calls in a database and groups them by the sourceTN counting calls.  The query and result is below.  My questions is I need to be able to store each row (sourceTN and Calls) into a temporary variable so I can crank it through and IF statement to see if a telephone number has a value greater then 10.  Something like...

IF Calls > 10
THEN
  # do some actions with the SourceTN


Query:
SELECT src as SourceTN, COUNT(src) as Calls FROM cdr GROUP BY src;"

Open in new window



+------------+-------+
| SourceTN   | Calls |
+------------+-------+
| 2012680000 |    27 | 
| 2016240000 |     1 | 
| 2018160000 |     2 | 
| 2018160000 |     5 | 
| 2018160000 |     7 | 
| 2018160000 |     9 | 
| 2018160000 |     1 | 
| 2018160000 |     4 | 
 

Open in new window

0
Comment
Question by:ipconfig610
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
Manuel Marienne-Duchêne earned 500 total points
ID: 39228766
SELECT SOURCETN,CASE WHEN CALLS > 10 THEN ....ELSE .... END FROM (SELECT src as SourceTN, COUNT(src) as Calls FROM cdr GROUP BY src) TABLE1
0
 
LVL 38

Expert Comment

by:Gerwin Jansen, EE MVE
ID: 39232698
Where is the output of your query going? To some temporary file perhaps?

In case the output goes to a temporary file, you could parse the file and search for lines matching your 'clause' > 10 calls using awk for example.

If possible can you post (part of your) script?
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question