Working with (Easy web hosting) MySQL SQL 50 mysql> SELECT *

Working with MySQL SQL 50 mysql> SELECT * FROM acc WHERE acc_id = ‘1034055′; +——–+——–+———-+—————-+—————+ |acc_id |username| password | ts | act_ts | +——–+——–+———-+—————-+—————+ |1034055 | jdoe | ime | 20021014212553 | 20021014212444| +——–+——–+———-+—————-+—————+ 1 row in set (0.01 sec) Now we can insert the new row: mysql> INSERT INTO acc VALUES(1034055, ‘jdoe’, ‘newpass’, 0, @time); Query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 A final SELECT will show both of the rows and how they relate through the act_ts column of the new row and the ts of the old row: mysql> SELECT * FROM acc WHERE acc_id = ‘1034055′; +——-+——–+———-+—————-+—————-+ |acc_id |username| password | ts | act_ts | +——-+——–+———-+—————-+—————-+ |1034055| jdoe | newpass | 00000000000000 | 20021014212553 | |1034055| jdoe | ime | 20021014212553 | 20021014212444 | +——-+——–+———-+—————-+—————-+ 2 rows in set (0.01 sec) We can always know the active row by including ts=0 in our queries. Deletes When data is no longer needed in a database, you can use the DELETE command to remove a row. However, if you want to maintain the history of the rows in the database, you should instead make the row inactive. First, let s show the removal of a row. The query looks like this: DELETE FROM acc WHERE acc_id = ‘1034154′; The query will select the appropriate row based on the WHERE clause. Another use of the DELETE command is: DELETE FROM acc; This query doesn t include a WHERE clause and thus will remove all rows from the specified database table. To maintain the history of the rows in the database, you shouldn t use the DELETE command because the row will be permanently removed. In that case, the best way to delete the row is to make the row inactive by setting the ts of the row to a timestamp other than 0. In most cases, you want to update the current row to a current timestamp value so that the row has a record of when it was made inactive.
Note: If you are looking for top 10 and very good webhost to host and run your jsp application check Actions jsp hosting services

Comments are closed.