Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

bash MySQL result into array

Posted on 2013-06-07
2
Medium Priority
?
620 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
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.
Suggested Courses

610 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