Re: Loop on mysql output with bash

From: Luuk <luuk_at_invalid.lan>
Date: Sat, 17 Mar 2018 16:02:54 +0100
Message-ID: <5aad2e13$0$10818$e4fe514c_at_news.xs4all.nl>


On 12-3-2018 17:24, Boubaker Idir wrote:
> 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
> array=$(mysql -u root -pMyPassword -s -N <<QUERY_INPUT
> use myDatabase;
> SELECT packetid FROM wifi;
> QUERY_INPUT
> );
>

This van be simplified to:
#!/bin/bash
array=$(mysql myDatabase -u root -pMyPassword -s -N <<QUERY_INPUT SELECT packetid FROM wifi;
QUERY_INPUT
);

Or even to:
#!/bin/bash
array=$(mysql myDatabase -u root -pMyPassword -s -N -Be "SELECT packetid FROM wifi") Received on Sat Mar 17 2018 - 16:02:54 CET

Original text of this message