Page 1 of 1

sql command to delete all the sip/iax phones from goautodial

PostPosted: Wed Apr 06, 2011 1:21 pm
by striker
hi

goautodial | single server | 2.2.1 | BUILD: 100510-2015 | no hardware

i have seen the file sip-iax_phones.sql

what command to be replaced to delete all the phones from the phones table.

in that file it is
INSERT into phones (extension,dialplan_number,voicemail_id,server_ip,login,pass,status,active,phone_type,fullname,protocol,local_gmt,outbound_cid) values('cc350','350','350','10.10.10.15','350','test','ACTIVE','Y','CCagent','station 350','IAX2','-5','0000000000');

PostPosted: Wed Apr 06, 2011 1:38 pm
by williamconley
delete from phones where FIELD='VALUE'

or

delete from phones where FIELD like 'VALUE%'

mysql sysntax error

PostPosted: Wed Apr 06, 2011 1:46 pm
by striker
this is wat i have in that sql file

DELETE FROM phones where FIELD='VALUE' (extension,dialplan_number,voicemail_id,server_ip,login,pass,status,active,phone_type,fullname,protocol,local_gmt,outbound_cid) values('cc350','350','350','10.10.10.15','350','test','ACTIVE','Y','CCagent','station 350','IAX2','-5','0000000000');

also tried value%

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'values('cc350','350','350','10.10.10.15','350','test','ACTIVE','Y','CCagent','st' at line 1

PostPosted: Wed Apr 06, 2011 2:16 pm
by williamconley
lol
replace "FIELD" with the name of a field.

replace "VALUE" with a value (if exact)

or

replace "VALUE%" with a value and % (if "begins with VALUE" is your goal)

it is not necessary to specify every value of the record to delete. merely a single unique value (such as cc350?). if you want to get rid of all "cc3XX" phones, you can use cc3% in the "like" version of the query.

like this:

Code: Select all
delete from phones where extension like 'cc3%';
this will delete all extensions that begin with cc3 (note the ; which is necessary if usng at the command line but optional if in phpMyAdmin or webmin's sql execution)

PostPosted: Thu Apr 07, 2011 12:30 am
by DhwaniTechnologies
If you want to delete ALL phones from the table, just use:
Code: Select all
delete from phones;

thanks (SOLVED)

PostPosted: Thu Apr 07, 2011 1:11 am
by striker
Thanks william /dhawanitech


the command which u provided works great and it saved my time by deleting one by one.