Prev | Current Page 304 | Next

David Berube

"Practical Reporting with Ruby and Rails"

SQL itself can be used for reporting from the
MySQL client. This approach is very useful if you want to find a few pieces of information
(or just one). Let??™s use a SQL query to verify that the data has been inserted into the
MySQL database, as shown in Listing 11-2.
Listing 11-2. SQL to Verify Data Loading
mysql company_pr -u your_mysql_username -p
Password: your_password_here
mysql> SELECT id,
CONCAT(LEFT(title,40),
CASE WHEN(LENGTH(title)>40)
THEN '...'
ELSE '' END) AS story_title
FROM stories;
Running the query in Listing 11-2 produces results similar to the following:
+-----+---------------------------------------------+
| id | story_title |
+-----+---------------------------------------------+
| 1 | Judge approves final settlement in Iowa ... |
| 2 | Microsoft Webcast: Security Series (Part... |
| 3 | Security Showdown - Redmond Channel Part... |
| 4 | Linux: Hasta la Vista, Microsoft! - LXer... |
| 5 | Microsoft Vista desktops don't play... |
| 6 | Major Computer Viruses Over 25 Years - F.


Pages:
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
willa karmazyn międzyzdroje www.books61.hobbitstory.com terapia magnetyczna Informacje o hostingu asus netbooki