forum

Home / DeveloperSection / Forums / Delete if condition met in a column

Delete if condition met in a column

Anonymous User245108-Apr-2013
Hi Expert!

i have a table like this:

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:

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:

    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.

Thanks in advance!

Updated on 08-Apr-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By