Introducing MySQL SQL 47 mysql> (Easy web hosting) SELECT * FROM
Introducing MySQL SQL 47 mysql> SELECT * FROM acc INTO OUTFILE ‘test.outfile’; Query OK, 8 rows affected (0.00 sec) This query results in a text file with all of the rows, as shown here: 1034033 jsmith smithy 20021014165845 1034034 jime N 20021014165845 1034067 jthompson james2 20021014165845 1034089 sstanford stanford 20021014165845 1034123 blewis lewis 20021014165845 1034154 ysheets sheets 20021014165845 1034546 jjmyers N 20021014165845 1034055 jdoe doey 20021014165908 Notice that the NULL values are converted to N and line terminations are provided. If you need the data sorted, you can add the appropriate clauses to the query. MySQL also includes the clause INTO DUMPFILE, which basically dumps a single row into a file without any sort of special processing. The DUMPFILE is typically used to output a BLOB to a file. Our sample database doesn t include a BLOB, but the query might look like the following: SELECT pic_blob FROM images INTO DUMPFILE ‘world.jpg’ WHERE pic_name = ‘World’; Counting If you consider the various SELECT queries we ve created in this section, you will note that they all output some number of result rows. What if we want a query that counts the total number of rows in a result? The total count can be returned using the count(*) option. For example: mysql> SELECT count(*) FROM acc; +———-+ | count(*) | +———-+ | 8 | +———-+ 1 row in set (0.00 sec) Here we execute a SELECT to return the total number of rows in the acc table. Notice that the count value is returned as a column in the result. The column heading value can be changed, as we explained earlier in this section. Updates The first major SQL statement we covered was INSERT, which you use to place data into your database. This was followed by the SELECT statement, which you use to pull the data from your database. What do you do if you want to change the data within a row? You have two options. The first is to just make the change. You can do this with the UPDATE command:
Hint: If you are looking for very good and affordable webspace to host and run your tomcat hosting application check Sandzak.com tomcat web hosting provider