Jump to content

Deleting records from two tables


PRodgers4284

Recommended Posts

Im want to delete records from two tables, the tables are called "employers" and "job". I am want to delete records based on the username in each table.

 

Im using the following query but im not sure if the syntax is correct for deleting from two tables:

 

 

mysql_query("DELETE FROM employers && job WHERE username='$username'");

 

Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/96393-deleting-records-from-two-tables/
Share on other sites

Hey thanks for the reply, i tried the query you suggested, but it doesnt same to be deleting the records, below is the php code I have now:

 

<?php  
$username = $_GET['username'];

if (isset($_POST['submit'])) { 


   mysql_query("DELETE FROM employers e , job j WHERE e.username = j.username AND e.username = '$username'"); 
  


?>  
           
<br /> 
<a href="Indexadmin.php">Back to main page</a> 
<br /> 
<br /> 
<br /> 
The Employer account for <b><?php echo $username; ?></b> has been deleted from the system 
<?php  
}  
else  
{  

$account = mysql_fetch_array(mysql_query("SELECT * FROM employers WHERE username='$username'")); 

?>  

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.