* Gael Jobard <jo...@cy...> [2005-05-18 12:10]:
> Hi all,
>
> Does anyone know how to delete all the respondents that have been
> entered in the database (without resetting all of it)? That would save
> me hundreds and hundreds of clicks.
> Thanks!
>
> Gael.
Hi Gael,
Well, first you want to know how many respondents there are.
The 'respondent' table holds this information.
(All SQL statements below can be run from the MySQL monitor.)
Use
SELECT COUNT(*) FROM respondent;
to find the number of records in the respondent table.
To delete a specific record, use the DELETE SQL statement.
DELETE FROM respondent WHERE username LIKE 'Sally';
To delete multiple records, use the LIKE wildcard operator '%'
DELETE FROM respondent WHERE username LIKE 'Sa%';
This statement will delete all records where the username
starts with 'Sa', such as 'Sam', 'Sally', 'Sarah', 'Samantha', etc.
Before you use the DELETE statement, it's best to count
how many records will be deleted. Use the SELECT COUNT(*) statement
as above, but with a WHERE clause.
SELECT COUNT(*) FROM respondent WHERE username LIKE 'Sa%';
+----------+
| count(*) |
+----------+
| 437 |
+----------+
437 rows in set (0.00 sec)
then use the DELETE statement
DELETE FROM respondent WHERE username LIKE 'Sa%';
If you really, really want to delete all records in the respondent table
just leave off the WHERE clause.
DELETE FROM respondent;
I haven't looked through the entire code, but it looks like you can
delete respondents without risking failure with a survey.
Test on a separate database if possible.
Hope this helps,
Jim B.
|