Working with MySQL SQL 40 Let s examine the INSERT command a little more closely. First consider the order of the data. The order must match the columns defined in the table as shown by the DESCRIBE command. The second important factor is the use of single quotes to indicate a value is a string and should be treated as such by MySQL. If you didn t want to insert a password into a row, you could use a NULL value. For example: mysql> INSERT INTO acc VALUES(1034034, ‘jime’, NULL, now()); Query OK, 1 row affected (0.00 sec) In this example, the NULL value is placed directly into the database in place of a string value. Selects Once you ve inserted your data into a database, you can extract that data to make business decisions. You pull data from the database by using the SELECT command, which has the following format: SELECT FROM WHERE The SELECT command has three different components at its core. The first is the element, which tells the database the columns where values should be returned. The element can be * (representing all columns) or a list of columns separated by commas. The second component is the element, which represents the exact table from which the data should come. The third component is the element, which represents under what conditions the data should be pulled from the database. First, we pull data using the simplest SELECT: mysql> select * from acc; +———+———–+———-+—————-+ | acc_id | username | password | ts | +———+———–+———-+—————-+ | 1034033 | jsmith | smithy | 20021014112438 | | 1034055 | jdoe | doey | 20021014112501 | | 1034067 | jthompson | james2 | 20021014113403 | | 1034089 | sstanford | stanford | 20021014113407 | | 1034123 | blewis | lewis | 20021014112252 | | 1034154 | ysheets | sheets | 20021014113416 | | 1034034 | jime | NULL | 20021014112415 | | 1034546 | jjmyers | NULL | 20021014113422 | +———+———–+———-+—————-+ 8 rows in set (0.00 sec)
Hint: If you are looking for high quality webhost to host and run your jsp application check Vision web hosting jsp services
This entry was posted
on Sunday, December 17th, 2006 at 3:13 am and is filed under developing.
You can follow any responses to this entry through the RSS 2.0 feed.
Responses are currently closed, but you can trackback from your own site.