Link to home
Start Free TrialLog in
Avatar of ipconfig610
ipconfig610Flag for United States of America

asked on

bash MySQL result into array

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

ASKER CERTIFIED SOLUTION
Avatar of Manuel Marienne-Duchêne
Manuel Marienne-Duchêne
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gerwin Jansen
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?