Loop on mysql output with bash

From: Boubaker Idir <boubaker.idir_at_gmail.com>
Date: Mon, 12 Mar 2018 09:24:11 -0700 (PDT)
Message-ID: <7105d732-b7cc-4a7b-92e3-76b7942d8991_at_googlegroups.com>



[Quoted] [Quoted] Hello everybody, I need to do a loop on my mysql output (packetid) and put it everytime on the second SELECT command, to have a result for each packetid and put it everytime on text file. can you help me please? Thank you so much

#!/bin/bash
[Quoted] [Quoted] array=$(mysql -u root -pMyPassword -s -N <<QUERY_INPUT use myDatabase;
SELECT packetid FROM wifi;
QUERY_INPUT
);

[Quoted] echo "${array[_at_]}";

for i in "${array[_at_]}" do

variable=$(mysql -u root -pMyPassword -s -N <<QUERY_INPUT use myDatabase;
SELECT CONCAT("{""wlan"": [",GROUP_CONCAT(JSON_OBJECT("mac",bssid,"powrx",rssi)), "]}") FROM wifi WHERE packetid=$i; QUERY_INPUT
);

echo $variable>text2.txt;
done Received on Mon Mar 12 2018 - 17:24:11 CET

Original text of this message