I need a bash script which reads from csv 2 values per line and use it in mysql query.
The .csv contains about +3k lines like this:
FA63MZ6,200000000163,2020-06-27,CF,Name Surname1 Surname1
FA63MZ6,200000000163,2020-06-27,CF,Name2 Surname2 Surname2
I would like to extract "date" and "Name Surname1 Surname1" as variables to use it in a mysql query.
I am triying with :
echo "select status from invoices where date_created= \"${date01}\" and customer_id in (select id from customers where name = \"${name01}\" );" | mysql -u user -pPassword -D dbname | grep -v status
Ideally this script could be create a .csv with the result of query:
FA63MZ6,200000000163,2020-06-27,CF,Name Surname1 Surname1,paid
FA63MZ6,200000000164,2020-06-27,CF,Name2 Surname2 Surname2,not_paid
Thanks in advance,