Home > DeveloperSection > Forums > Delete if condition met in a column
Ankit Singh

Total Post:341

Posted on    April-08-2013 2:17 AM


 1 Reply(s)
 952  View(s)
Rate this:
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!


Total Post:604

Posted on    April-08-2013 7:35 AM

Hi Ankita!

try this way

mysql -uroot -pabcde smsd -e "DELETE FROM inbox WHERE senderNumber like =".$BLOCKLIST

Don't want to miss updates? Please click the below button!

Follow MindStick