I have two tables resume_update and wp_rsjp_submissions
When I do a union of both tables I can fetch the records successfully but delete is not working. I have this query
<?php
include('wp-blog-header.php');
if($_POST['id']) {
$id=$_POST['id'];
//echo($id); enter code here
//$sql = "delete from user where id='$id'";`enter code here`global $wpdb;
$row = $wpdb->get_row("delete from wp_rsjp_submissions, resume_update using wp_rsjp_submissions, resume_update where id='$id'");
}
?>
In the official documentation for $wpdb
seen here, you will see that get_row()
is used to return a row.
To retrieve an entire row from a query, use get_row.
If you want to delete, you can use $wpdb->delete()
or $wpdb->query()
.
Use the following code instead.
<?php
include('wp-blog-header.php');
if($_POST['id']) {
$id=$_POST['id'];
//echo($id); enter code here
//$sql = "delete from user where id='$id'";`enter code here`global $wpdb;
$sql = $wpdb->prepare("delete from wp_rsjp_submissions, resume_update using wp_rsjp_submissions, resume_update where id=%d" , array($id));
$return = $wpdb->query($sql);
}
?>
Also be sure to test your sql directly in mysql. I do not think this sql would work anyway.