Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to edit or delete data in MySQL

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 31-12-2010
Member
 
Join Date: Jul 2010
Posts: 32
How to edit or delete data in MySQL
  

I have recently started practicing with the MySQL. First let me tell you that I have not done anything in it, but still I want to gain more knowledge about it. I want to clear some basic concepts that are very important before moving in deep. Also another reason, I think, that even if I start tutorials for that, I am sure that they are not going to waste their time in teaching the basic things. So I want to clear all the basic things and then I can attend the tutorials. I am sure that you people will be kind enough to help me. For now, I am looking for editing and deleting data that we create in MySQL. In short, please tell me how to edit or delete data in MySQL?

Reply With Quote
  #2  
Old 31-12-2010
Member
 
Join Date: Feb 2010
Posts: 125
Re: How to edit or delete data in MySQL

For updated using the UPDATE statement, of which we see the syntax:
Code:
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name 
December column_name = expression [name_column2 = expr2 ...] 
[WHERE conditions] 
[ORDER BY ...] 
[LIMIT row_number]
The operation is fairly intuitive:
  • UPDATE after we indicate which table is affected
  • with SET specify which columns to change and what values to assign
  • WHERE to establish the conditions that determine which rows will be affected by the changes (if you do not specify a WHERE clause all rows will be changed)
Reply With Quote
  #3  
Old 31-12-2010
Member
 
Join Date: Feb 2010
Posts: 669
Re: How to edit or delete data in MySQL

We can also use ORDER BY to decide in what order do the updates on the lines, and limited to set a maximum number of rows that will be affected. Evidently the use of ORDER BY hardly makes sense unless coupled with limitations. The UPDATE returns the number of rows changed, mind you: if you try to assign values to a line equal to those that already, MySQL notices it and does not update. In mitigating the line will still be counted. You can also use LOW_PRIORITY, as already seen for the INSERT, to delay the execution of the update at a time when the table is not committed by other clients. By ignoring the clause tells the server to ignore the errors generated by the update. Any changes that cause double keys will not, in this case, do.
Reply With Quote
  #4  
Old 31-12-2010
Member
 
Join Date: Feb 2010
Posts: 137
Re: How to edit or delete data in MySQL

In an UPDATE, you can refer to a column to use its value before the update, for example:
Code:
UPDATE sales set they sell sold = +1 WHERE idSeller= 5;
In this case the value of the sold column is incremented by 1. The UPDATE operation can also be performed on multiple tables. Mention the names of the affected tables with the same syntax you already know from the join. With multi-table updates but you can not use ORDER BY and LIMIT clauses. To make an UPDATE you must have UPDATE privilege on the tables to be amended as the SELECT privilege on any other tables to which it is made read-only access.
Reply With Quote
  #5  
Old 31-12-2010
Member
 
Join Date: Feb 2010
Posts: 592
Re: How to edit or delete data in MySQL

Even as ORDER BY and LIMIT work in UPDATE: possible to establish the order of cancellation and to limit the number of rows deleted. With the WHERE establish the conditions under which rows will be deleted. If not indicated, all lines will be eliminated. The deletion of rows from a table can lead to the presence of unused space in that table: if you perform many DELETE on a table will always make a regular run OPTIMIZE TABLE. Here's how to make a multiple-table DELETE: this step there are two possible syntax :
Code:
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] 
table_name [.*] [, table_name [.*] ...] 
FROM tables 
[WHERE conditions] 
or 
DELETE [LOW_PRIORITY] [QUICK] [IGNORE] 
FROM table_name [.*] [, table_name [.*] ...] 
USING tables 
[WHERE conditions]
In this case it may happen that we need to delete rows from a table or tables when reading data from other tables without deleting anything from them. The tables suffer cancellations are listed after the first DELETE syntax, and after FROM in the second. The join on the tables from which to read the data is instead expressed in the FROM clause for the first case, and USING in the second.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to edit or delete data in MySQL"
Thread Thread Starter Forum Replies Last Post
PHP/MySQL - Delete article from database hARSH007 Software Development 4 04-11-2010 01:51 PM
Mysql Error : Can't connect to local mysql server through socket ' var lib mysql mysql.sock' 2 roshan45 Software Development 3 07-11-2009 09:36 PM
How to edit rows in MySQL DeMario Software Development 4 05-11-2009 08:50 PM
Add, Edit, Delete from one Form in SQL with ASP & JAVA Kanan Software Development 3 19-05-2009 09:53 AM
how to delete or edit a tuples via vb.net Aberto Software Development 3 16-01-2009 12:49 PM


All times are GMT +5.5. The time now is 08:40 PM.