Question: I created a form in wordpress but this code isn't work .

```
<?php

$metaname = $wpdb->escape($_REQUEST['apply_name']);
$metakey = $wpdb->escape($_REQUEST['apply_email']);
$metavalue = $wpdb->escape($_REQUEST['regcat']);

$wpdb->query($wpdb->prepare(
                "
        INSERT INTO $wpdb->jz_users
        ( user_login, user_email, category )
        VALUES ( %d, %s, %s )
    ", array(
            $metaname,
            $metakey,
            $metavalue
                )
        ));
?>

```

Answer: 
You could use a query like this:

```
db.execSQL("DELETE FROM " + TABLE_NAME +
           " WHERE " + currentdate + " - " + TIMESTAMP_DB + " > 2*24*60*60");

```

For the `update` method, write the SQL expression in the `WHERE` clause in the `whereClause` parameter; `whereArgs` is needed only for string values:

```
db.update(TABLE_NAME, currentdate + " - " + TIMESTAMP_DB + " > 2*24*60*60", null);

```
This is very "huge" question and can have more working approaches depend on your personal requirements e.q security, performance etc.

At first i recommend to you use parametrized statements instead of your "harcoded" which are unsafe and not much human readable, so use placeholders e.q.

```
select * from test where id = ?

```

Second, for delete rows from table use API build-in function [delete()](http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html). And as @Chintan Rathod pointed out, your delete statement is not valid statement.

Now to your question. Since you want to delete rows due to specified timestamp i suggest you to insert each row with specified date in certain date format (you can simply use [SimpleDateFormat](http://docs.oracle.com/javase/1.4.2/docs/api/java/text/SimpleDateFormat.html). Then there are more approaches how you can do it. I prefer at first query a table and place simple if condition if between actual date and date stored in row is difference 2 days then save his rowId. Finally, you have row's ids you want to delete.

But, right now you don't know exactly how many rows you want to delete so you need to:

1. delete records in loop (API is less than 11)
2. Create dynamically query with `IN` clause
3. Since Android API 11, there is method that allows delete multiple records. Here you can create "dynamic" statement due to size of ids (stored in some dynamic array).

Examples:
---------

**First approach:**

```
List<Integer> ids = new ArrayList<Integer>();
...
for (int id: ids) {
   db.delete("table", "_id = ?", new String[] {String.valueOf(id)});
}

```

**Second approach:**

```
List<Integer> ids = new ArrayList<Integer>();
...
StringBuilder b = new StringBuilder("delete from table where _id IN(");
String[] whereArgs = new String[ids.size()];
int index = 0;
for (int id: ids) {
   whereArgs[index] = String.valueOf(id);
   b.append("?");
   if (index < ids.size() - 1) {
      b.append(",");
   }
   index++;
}
b.append(")");

db.execSQL(b.toString(), whereArgs);

```

**Third approach:**

Same as above but you can use `SQLiteStatement`:

```
SQLiteDatabase db; // instantiated SQLiteDatabase
SQLiteStatement stm = db.compileStatement(b.toString());
stm.executeUpdateDelete();

```

**Note:** Since you want to delete multiple records (sometimes you need to delete 10 000 and more rows) try to think about `TRANSACTIONS` which rapidly increase performance and security.