Deleting a value in a column can be done in multiple ways in SQL, mileage will always vary. If you have been working in SQL for quite some time and you were able to get the pinch of SQL then single liner statements can be done easily.
Deleting a single field or a single value in a column that matches a string or data using SQL is a daunting task, so it's better to practice with a dummy data before executing the statement on a production database or else inadvertent consequences might happen.
One liner statement below will delete a value that matches the variable in query. Below is a PHP statemen that will delete a value in a column that matches the variable supplied on the statement.
The “.”, dot or period is a concatenation operator for strings in PHP.
"DELETE FROM `Table_Name` WHERE column_name = " . " ' " . $variable_query . " ' ";
Replace Table_Name with the actual table name and the column_name also with the actual column name.
The $variable_query can be any name, it’s just the variable name that will hold the data to be searched on the table column.
Once the queried variable matches the data on the column, then the data match will be deleted.
If not sure about how the statement works, it’s better to test with a dummy table and a dummy data and check whether that’s the ideal operation for your database.
The statement will loop through all the rows in the column until a match is found, if a match is found then it will be deleted. If no match is found then no deletion is performed.
Till next time. Cheers~!
================================
Free Android Apps:
Click links below to find out more:
Linux Android App cheat sheet:
Heaven's Dew Fall Prayer app for Android :
Catholic Rosary Guide for Android:
Divine Mercy Chaplet Guide (A Powerful prayer):
Comments
Post a Comment