V
V
Viktor Taran2020-01-20 19:45:36
MySQL
Viktor Taran, 2020-01-20 19:45:36

How to make a subquery in the database in SED?

The task is simple, you need to display in a new line the domain name from the subquery in the database by ID in the mail
I look at the mail queues

mailq|grep ^[A-F0-9] |cut -c 42-80| sort | uniq -c| sort -n

2 [email protected]
5 [email protected]
6 [email protected]
8 [email protected]
10 [email protected]
27 [email protected]

For the time being, we will leave only site IDs for convenience.
mailq|grep ^[A-F0-9] |cut -c 42-80| sed -e s'/.*web\([0-9]\{1,\}\)\(@ks03.ru\)$/\1 /'g

217
217
137
221
178
178
178
217
137
221
178
178
174
217
178
178
137
178
178
178
178
178

throw in an array
LIST=$(mailq|grep ^[A-F0-9] |cut -c 42-80| sed -e s'/.*web\([0-9]\{1,\}\)\(@ks02.ru\)$/\1 /'g)
echo $LIST

for ELEMENT in $LIST
    do
     $ELEMENT"
    mysql -uroot -p********* -N -B dbispconfig -e 'select domain  from 'web_domain' where 'domain_id'=$ELEMENT;'

  done

And then if the print is done, then everything works, but if you immediately execute it, then the sequel writes an error.
I can't figure out which quotes to remove and what to escape.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman MySQL, 2020-01-20
Tag

'web_domain', 'domain_id' in request context - string constants
`web_domain` - table
`domain_id` - field
' => `

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question