Tag Archives: BLOCKLIST

Delete if condition met in a column

By jazzyzha

i have a table like this:

Code:

id, senderNumber, blacklist
-----------------------------
1 0835636326 Y
2 0373562343 Y
3 0273646833 Y


and I want to delete automatically if a new inserted row on another table consist anything on senderNumber column above using a BASH Script

I already using this script:

Code:

BLOCKLIST="$( mysql -uroot -pabcde smsd -N -s -r -e "SELECT senderNumber FROM blacklist WHERE senderBlock='Y'" | tr 'n' ' ')"
mysql -uroot -pabcde smsd -e "DELETE FROM inbox WHERE senderNumber = '$BLOCKLIST'"


and this the output:

Code:

sh -x /etc/autodelete.sh
+ tr n
+ mysql -uroot -pabcde smsd -N -s -r -e SELECT senderNumber FROM blacklist WHERE senderBlock='Y'
+ BLOCKLIST=083808034690 08164853500
+ mysql -uroot -pabcde smsd -e DELETE FROM inbox WHERE senderNumber = '083808034690 08164853500 '


but no luck. any help would be very appreciated.

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums