SlideShare a Scribd company logo
Visit ebookfinal.com to download the full version and
explore more ebooks or textbooks
MySQL Cookbook 1st ed Edition Paul Dubois
_____ Click the link below to download _____
https://ebookfinal.com/download/mysql-cookbook-1st-ed-
edition-paul-dubois/
Explore and download more ebooks or textbook at ebookfinal.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
MySQL Cookbook 2nd Edition Solutions Examples for Database
Developers and DBAs Paul Dubois
https://ebookfinal.com/download/mysql-cookbook-2nd-edition-solutions-
examples-for-database-developers-and-dbas-paul-dubois/
MySQL Admin Cookbook 1st New edition Edition Daniel
Schneller
https://ebookfinal.com/download/mysql-admin-cookbook-1st-new-edition-
edition-daniel-schneller/
MySQL Cookbook 4th Edition Sveta Smirnova & Alkin Tezuysal
https://ebookfinal.com/download/mysql-cookbook-4th-edition-sveta-
smirnova-alkin-tezuysal/
Useful Quasicrystals 1st Edition Jean-Marie Dubois
https://ebookfinal.com/download/useful-quasicrystals-1st-edition-jean-
marie-dubois/
Python Cookbook 2nd ed Edition Alex Martelli
https://ebookfinal.com/download/python-cookbook-2nd-ed-edition-alex-
martelli/
Linux Security Cookbook 1st ed Edition Daniel J. Barrett
https://ebookfinal.com/download/linux-security-cookbook-1st-ed-
edition-daniel-j-barrett/
Access Data Analysis Cookbook 1st ed Edition Ken Bluttman
https://ebookfinal.com/download/access-data-analysis-cookbook-1st-ed-
edition-ken-bluttman/
Analog Circuits Cookbook 2nd ed Edition Ian Hickman
https://ebookfinal.com/download/analog-circuits-cookbook-2nd-ed-
edition-ian-hickman/
MySQL Crash Course Rick Silva
https://ebookfinal.com/download/mysql-crash-course-rick-silva/
MySQL Cookbook 1st ed Edition Paul Dubois
MySQL Cookbook 1st ed Edition Paul Dubois Digital
Instant Download
Author(s): Paul DuBois
ISBN(s): 9780596001452, 0596001452
Edition: 1st ed
File Details: PDF, 4.00 MB
Year: 2003
Language: english
MySQL Cookbook
By Paul DuBois
Publisher : O'Reilly
Pub Date : October 2002
ISBN : 0-596-00145-2
Pages : 1022
MySQL Cookbook provides a unique problem-and-solution format that offers practical
examples for everyday programming dilemmas. For every problem addressed in the book,
there's a worked-out solution or "recipe" -- short, focused pieces of code that you can insert
directly into your applications. More than a collection of cut-and-paste code, this book
explanation how and why the code works, so you can learn to adapt the techniques to similar
situations.
Copyright
Preface
MySQL APIs Used in This Book
Who This Book Is For
What's in This Book
Platform Notes
Conventions Used in This Book
The Companion Web Site
Comments and Questions
Additional Resources
Acknowledgments
Chapter 1. Using the mysql Client Program
Section 1.1. Introduction
Section 1.2. Setting Up a MySQL User Account
Section 1.3. Creating a Database and a Sample Table
Section 1.4. Starting and Terminating mysql
Section 1.5. Specifying Connection Parameters by Using Option Files
Section 1.6. Protecting Option Files
Section 1.7. Mixing Command-Line and Option File Parameters
Section 1.8. What to Do if mysql Cannot Be Found
Section 1.9. Setting Environment Variables
Section 1.10. Issuing Queries
Section 1.11. Selecting a Database
Section 1.12. Canceling a Partially Entered Query
Section 1.13. Repeating and Editing Queries
Section 1.14. Using Auto-Completion for Database and Table Names
Section 1.15. Using SQL Variables in Queries
Section 1.16. Telling mysql to Read Queries from a File
Section 1.17. Telling mysql to Read Queries from Other Programs
Section 1.18. Specifying Queries on the Command Line
Section 1.19. Using Copy and Paste as a mysql Input Source
Section 1.20. Preventing Query Output from Scrolling off the Screen
Section 1.21. Sending Query Output to a File or to a Program
Section 1.22. Selecting Tabular or Tab-Delimited Query Output Format
Section 1.23. Specifying Arbitrary Output Column Delimiters
Section 1.24. Producing HTML Output
Section 1.25. Producing XML Output
Section 1.26. Suppressing Column Headings in Query Output
Section 1.27. Numbering Query Output Lines
Section 1.28. Making Long Output Lines More Readable
Section 1.29. Controlling mysql's Verbosity Level
Section 1.30. Logging Interactive mysql Sessions
Section 1.31. Creating mysql Scripts from Previously Executed Queries
Section 1.32. Using mysql as a Calculator
Section 1.33. Using mysql in Shell Scripts
Chapter 2. Writing MySQL-Based Programs
Section 2.1. Introduction
Section 2.2. Connecting to the MySQL Server, Selecting a Database, and Disconnecting
Section 2.3. Checking for Errors
Section 2.4. Writing Library Files
Section 2.5. Issuing Queries and Retrieving Results
Section 2.6. Moving Around Within a Result Set
Section 2.7. Using Prepared Statements and Placeholders in Queries
Section 2.8. Including Special Characters and NULL Values in Queries
Section 2.9. Handling NULL Values in Result Sets
Section 2.10. Writing an Object-Oriented MySQL Interface for PHP
Section 2.11. Ways of Obtaining Connection Parameters
Section 2.12. Conclusion and Words of Advice
Chapter 3. Record Selection Techniques
Section 3.1. Introduction
Section 3.2. Specifying Which Columns to Display
Section 3.3. Avoiding Output Column Order Problems When Writing Programs
Section 3.4. Giving Names to Output Columns
Section 3.5. Using Column Aliases to Make Programs Easier to Write
Section 3.6. Combining Columns to Construct Composite Values
Section 3.7. Specifying Which Rows to Select
Section 3.8. WHERE Clauses and Column Aliases
Section 3.9. Displaying Comparisons to Find Out How Something Works
Section 3.10. Reversing or Negating Query Conditions
Section 3.11. Removing Duplicate Rows
Section 3.12. Working with NULL Values
Section 3.13. Negating a Condition on a Column That Contains NULL Values
Section 3.14. Writing Comparisons Involving NULL in Programs
Section 3.15. Mapping NULL Values to Other Values for Display
Section 3.16. Sorting a Result Set
Section 3.17. Selecting Records from the Beginning or End of a Result Set
Section 3.18. Pulling a Section from the Middle of a Result Set
Section 3.19. Choosing Appropriate LIMIT Values
Section 3.20. Calculating LIMIT Values from Expressions
Section 3.21. What to Do When LIMIT Requires the "Wrong" Sort Order
Section 3.22. Selecting a Result Set into an Existing Table
Section 3.23. Creating a Destination Table on the Fly from a Result Set
Section 3.24. Moving Records Between Tables Safely
Section 3.25. Creating Temporary Tables
Section 3.26. Cloning a Table Exactly
Section 3.27. Generating Unique Table Names
Chapter 4. Working with Strings
Section 4.1. Introduction
Section 4.2. Writing Strings That Include Quotes or Special Characters
Section 4.3. Preserving Trailing Spaces in String Columns
Section 4.4. Testing String Equality or Relative Ordering
Section 4.5. Decomposing or Combining Strings
Section 4.6. Checking Whether a String Contains a Substring
Section 4.7. Pattern Matching with SQL Patterns
Section 4.8. Pattern Matching with Regular Expressions
Section 4.9. Matching Pattern Metacharacters Literally
Section 4.10. Controlling Case Sensitivity in String Comparisons
Section 4.11. Controlling Case Sensitivity in Pattern Matching
Section 4.12. Using FULLTEXT Searches
Section 4.13. Using a FULLTEXT Search with Short Words
Section 4.14. Requiring or Excluding FULLTEXT Search Words
Section 4.15. Performing Phrase Searches with a FULLTEXT Index
Chapter 5. Working with Dates and Times
Section 5.1. Introduction
Section 5.2. Changing MySQL's Date Format
Section 5.3. Telling MySQL How to Display Dates or Times
Section 5.4. Determining the Current Date or Time
Section 5.5. Decomposing Dates and Times Using Formatting Functions
Section 5.6. Decomposing Dates or Times Using Component-Extraction Functions
Section 5.7. Decomposing Dates or Times Using String Functions
Section 5.8. Synthesizing Dates or Times Using Formatting Functions
Section 5.9. Synthesizing Dates or Times Using Component-Extraction Functions
Section 5.10. Combining a Date and a Time into a Date-and-Time Value
Section 5.11. Converting Between Times and Seconds
Section 5.12. Converting Between Dates and Days
Section 5.13. Converting Between Date-and-Time Values and Seconds
Section 5.14. Adding a Temporal Interval to a Time
Section 5.15. Calculating Intervals Between Times
Section 5.16. Breaking Down Time Intervals into Components
Section 5.17. Adding a Temporal Interval to a Date
Section 5.18. Calculating Intervals Between Dates
Section 5.19. Canonizing Not-Quite-ISO Date Strings
Section 5.20. Calculating Ages
Section 5.21. Shifting Dates by a Known Amount
Section 5.22. Finding First and Last Days of Months
Section 5.23. Finding the Length of a Month
Section 5.24. Calculating One Date from Another by Substring Replacement
Section 5.25. Finding the Day of the Week for a Date
Section 5.26. Finding Dates for Days of the Current Week
Section 5.27. Finding Dates for Weekdays of Other Weeks
Section 5.28. Performing Leap Year Calculations
Section 5.29. Treating Dates or Times as Numbers
Section 5.30. Forcing MySQL to Treat Strings as Temporal Values
Section 5.31. Selecting Records Based on Their Temporal Characteristics
Section 5.32. Using TIMESTAMP Values
Section 5.33. Recording a Row's Last Modification Time
Section 5.34. Recording a Row's Creation Time
Section 5.35. Performing Calculations with TIMESTAMP Values
Section 5.36. Displaying TIMESTAMP Values in Readable Form
Chapter 6. Sorting Query Results
Section 6.1. Introduction
Section 6.2. Using ORDER BY to Sort Query Results
Section 6.3. Sorting Subsets of a Table
Section 6.4. Sorting Expression Results
Section 6.5. Displaying One Set of Values While Sorting by Another
Section 6.6. Sorting and NULL Values
Section 6.7. Controlling Case Sensitivity of String Sorts
Section 6.8. Date-Based Sorting
Section 6.9. Sorting by Calendar Day
Section 6.10. Sorting by Day of Week
Section 6.11. Sorting by Time of Day
Section 6.12. Sorting Using Substrings of Column Values
Section 6.13. Sorting by Fixed-Length Substrings
Section 6.14. Sorting by Variable-Length Substrings
Section 6.15. Sorting Hostnames in Domain Order
Section 6.16. Sorting Dotted-Quad IP Values in Numeric Order
Section 6.17. Floating Specific Values to the Head or Tail of the Sort Order
Section 6.18. Sorting in User-Defined Orders
Section 6.19. Sorting ENUM Values
Chapter 7. Generating Summaries
Section 7.1. Introduction
Section 7.2. Summarizing with COUNT( )
Section 7.3. Summarizing with MIN( ) and MAX( )
Section 7.4. Summarizing with SUM( ) and AVG( )
Section 7.5. Using DISTINCT to Eliminate Duplicates
Section 7.6. Finding Values Associated with Minimum and Maximum Values
Section 7.7. Controlling String Case Sensitivity for MIN( ) and MAX( )
Section 7.8. Dividing a Summary into Subgroups
Section 7.9. Summaries and NULL Values
Section 7.10. Selecting Only Groups with Certain Characteristics
Section 7.11. Determining Whether Values are Unique
Section 7.12. Grouping by Expression Results
Section 7.13. Categorizing Non-Categorical Data
Section 7.14. Controlling Summary Display Order
Section 7.15. Finding Smallest or Largest Summary Values
Section 7.16. Date-Based Summaries
Section 7.17. Working with Per-Group and Overall Summary Values Simultaneously
Section 7.18. Generating a Report That Includes a Summary and a List
Chapter 8. Modifying Tables with ALTER TABLE
Section 8.1. Introduction
Section 8.2. Dropping, Adding, or Repositioning a Column
Section 8.3. Changing a Column Definition or Name
Section 8.4. The Effect of ALTER TABLE on Null and Default Value Attributes
Section 8.5. Changing a Column's Default Value
Section 8.6. Changing a Table Type
Section 8.7. Renaming a Table
Section 8.8. Adding or Dropping Indexes
Section 8.9. Eliminating Duplicates by Adding an Index
Section 8.10. Using ALTER TABLE to Normalize a Table
Chapter 9. Obtaining and Using Metadata
Section 9.1. Introduction
Section 9.2. Obtaining the Number of Rows Affected by a Query
Section 9.3. Obtaining Result Set Metadata
Section 9.4. Determining Presence or Absence of a Result Set
Section 9.5. Formatting Query Results for Display
Section 9.6. Getting Table Structure Information
Section 9.7. Getting ENUM and SET Column Information
Section 9.8. Database-Independent Methods of Obtaining Table Information
Section 9.9. Applying Table Structure Information
Section 9.10. Listing Tables and Databases
Section 9.11. Testing Whether a Table Exists
Section 9.12. Testing Whether a Database Exists
Section 9.13. Getting Server Metadata
Section 9.14. Writing Applications That Adapt to the MySQL Server Version
Section 9.15. Determining the Current Database
Section 9.16. Determining the Current MySQL User
Section 9.17. Monitoring the MySQL Server
Section 9.18. Determining Which Table Types the Server Supports
Chapter 10. Importing and Exporting Data
Section 10.1. Introduction
Section 10.2. Importing Data with LOAD DATA and mysqlimport
Section 10.3. Specifying the Datafile Location
Section 10.4. Specifying the Datafile Format
Section 10.5. Dealing with Quotes and Special Characters
Section 10.6. Importing CSV Files
Section 10.7. Reading Files from Different Operating Systems
Section 10.8. Handling Duplicate Index Values
Section 10.9. Getting LOAD DATA to Cough Up More Information
Section 10.10. Don't Assume LOAD DATA Knows More than It Does
Section 10.11. Skipping Datafile Lines
Section 10.12. Specifying Input Column Order
Section 10.13. Skipping Datafile Columns
Section 10.14. Exporting Query Results from MySQL
Section 10.15. Exporting Tables as Raw Data
Section 10.16. Exporting Table Contents or Definitions in SQL Format
Section 10.17. Copying Tables or Databases to Another Server
Section 10.18. Writing Your Own Export Programs
Section 10.19. Converting Datafiles from One Format to Another
Section 10.20. Extracting and Rearranging Datafile Columns
Section 10.21. Validating and Transforming Data
Section 10.22. Validation by Direct Comparison
Section 10.23. Validation by Pattern Matching
Section 10.24. Using Patterns to Match Broad Content Types
Section 10.25. Using Patterns to Match Numeric Values
Section 10.26. Using Patterns to Match Dates or Times
Section 10.27. Using Patterns to Match Email Addresses and URLs
Section 10.28. Validation Using Table Metadata
Section 10.29. Validation Using a Lookup Table
Section 10.30. Converting Two-Digit Year Values to Four-Digit Form
Section 10.31. Performing Validity Checking on Date or Time Subparts
Section 10.32. Writing Date-Processing Utilities
Section 10.33. Using Dates with Missing Components
Section 10.34. Performing Date Conversion Using SQL
Section 10.35. Using Temporary Tables for Data Transformation
Section 10.36. Dealing with NULL Values
Section 10.37. Guessing Table Structure from a Datafile
Section 10.38. A LOAD DATA Diagnostic Utility
Section 10.39. Exchanging Data Between MySQL and Microsoft Access
Section 10.40. Exchanging Data Between MySQL and Microsoft Excel
Section 10.41. Exchanging Data Between MySQL and FileMaker Pro
Section 10.42. Exporting Query Results as XML
Section 10.43. Importing XML into MySQL
Section 10.44. Epilog
Chapter 11. Generating and Using Sequences
Section 11.1. Introduction
Section 11.2. Using AUTO_INCREMENT To Set Up a Sequence Column
Section 11.3. Generating Sequence Values
Section 11.4. Choosing the Type for a Sequence Column
Section 11.5. The Effect of Record Deletions on Sequence Generation
Section 11.6. Retrieving Sequence Values
Section 11.7. Determining Whether to Resequence a Column
Section 11.8. Extending the Range of a Sequence Column
Section 11.9. Renumbering an Existing Sequence
Section 11.10. Reusing Values at the Top of a Sequence
Section 11.11. Ensuring That Rows Are Renumbered in a Particular Order
Section 11.12. Starting a Sequence at a Particular Value
Section 11.13. Sequencing an Unsequenced Table
Section 11.14. Using an AUTO_INCREMENT Column to Create Multiple Sequences
Section 11.15. Managing Multiple SimultaneousAUTO_INCREMENT Values
Section 11.16. Using AUTO_INCREMENT Valuesto Relate Tables
Section 11.17. Using Single-Row Sequence Generators
Section 11.18. Generating Repeating Sequences
Section 11.19. Numbering Query Output Rows Sequentially
Chapter 12. Using Multiple Tables
Section 12.1. Introduction
Section 12.2. Combining Rows in One Table with Rows in Another
Section 12.3. Performing a Join Between Tables in Different Databases
Section 12.4. Referring to Join Output Column Names in Programs
Section 12.5. Finding Rows in One Table That Match Rows in Another
Section 12.6. Finding Rows with No Match in Another Table
Section 12.7. Finding Rows Containing Per-Group Minimum or Maximum Values
Section 12.8. Computing Team Standings
Section 12.9. Producing Master-Detail Lists and Summaries
Section 12.10. Using a Join to Fill in Holes in a List
Section 12.11. Enumerating a Many-to-Many Relationship
Section 12.12. Comparing a Table to Itself
Section 12.13. Calculating Differences Between Successive Rows
Section 12.14. Finding Cumulative Sums and Running Averages
Section 12.15. Using a Join to Control Query Output Order
Section 12.16. Converting Subselects to Join Operations
Section 12.17. Selecting Records in Parallel from Multiple Tables
Section 12.18. Inserting Records in One Table That Include Values from Another
Section 12.19. Updating One Table Based on Values in Another
Section 12.20. Using a Join to Create a Lookup Table from Descriptive Labels
Section 12.21. Deleting Related Rows in Multiple Tables
Section 12.22. Identifying and Removing Unattached Records
Section 12.23. Using Different MySQL Servers Simultaneously
Chapter 13. Statistical Techniques
Section 13.1. Introduction
Section 13.2. Calculating Descriptive Statistics
Section 13.3. Per-Group Descriptive Statistics
Section 13.4. Generating Frequency Distributions
Section 13.5. Counting Missing Values
Section 13.6. Calculating Linear Regressions or Correlation Coefficients
Section 13.7. Generating Random Numbers
Section 13.8. Randomizing a Set of Rows
Section 13.9. Selecting Random Items from a Set of Rows
Section 13.10. Assigning Ranks
Chapter 14. Handling Duplicates
Section 14.1. Introduction
Section 14.2. Preventing Duplicates from Occurring in a Table
Section 14.3. Dealing with Duplicates at Record-Creation Time
Section 14.4. Counting and Identifying Duplicates
Section 14.5. Eliminating Duplicates from a Query Result
Section 14.6. Eliminating Duplicates from a Self-Join Result
Section 14.7. Eliminating Duplicates from a Table
Chapter 15. Performing Transactions
Section 15.1. Introduction
Section 15.2. Verifying Transaction Support Requirements
Section 15.3. Performing Transactions Using SQL
Section 15.4. Performing Transactions from Within Programs
Section 15.5. Using Transactions in Perl Programs
Section 15.6. Using Transactions in PHP Programs
Section 15.7. Using Transactions in Python Programs
Section 15.8. Using Transactions in Java Programs
Section 15.9. Using Alternatives to Transactions
Chapter 16. Introduction to MySQL on the Web
Section 16.1. Introduction
Section 16.2. Basic Web Page Generation
Section 16.3. Using Apache to Run Web Scripts
Section 16.4. Using Tomcat to Run Web Scripts
Section 16.5. Encoding Special Characters in Web Output
Chapter 17. Incorporating Query Resultsinto Web Pages
Section 17.1. Introduction
Section 17.2. Displaying Query Results as Paragraph Text
Section 17.3. Displaying Query Results as Lists
Section 17.4. Displaying Query Results as Tables
Section 17.5. Displaying Query Results as Hyperlinks
Section 17.6. Creating a Navigation Index from Database Content
Section 17.7. Storing Images or Other Binary Data
Section 17.8. Retrieving Images or Other Binary Data
Section 17.9. Serving Banner Ads
Section 17.10. Serving Query Results for Download
Chapter 18. Processing Web Input with MySQL
Section 18.1. Introduction
Section 18.2. Creating Forms in Scripts
Section 18.3. Creating Single-Pick Form Elements from Database Content
Section 18.4. Creating Multiple-Pick Form Elements from Database Content
Section 18.5. Loading a Database Record into a Form
Section 18.6. Collecting Web Input
Section 18.7. Validating Web Input
Section 18.8. Using Web Input to Construct Queries
Section 18.9. Processing File Uploads
Section 18.10. Performing Searches and Presenting the Results
Section 18.11. Generating Previous-Page and Next-Page Links
Section 18.12. Generating "Click to Sort" Table Headings
Section 18.13. Web Page Access Counting
Section 18.14. Web Page Access Logging
Section 18.15. Using MySQL for Apache Logging
Chapter 19. Using MySQL-Based Web Session Management
Section 19.1. Introduction
Section 19.2. Using MySQL-Based Sessions in Perl Applications
Section 19.3. Using MySQL-Based Storage with the PHP Session Manager
Section 19.4. Using MySQL for Session BackingStore with Tomcat
Appendix A. Obtaining MySQL Software
Section A.1. Obtaining Sample Source Code and Data
Section A.2. Obtaining MySQL and Related Software
Appendix B. JSP and Tomcat Primer
Section B.1. Servlet and JavaServer Pages Overview
Section B.2. Setting Up a Tomcat Server
Section B.3. Web Application Structure
Section B.4. Elements of JSP Pages
Appendix C. References
Section C.1. MySQL Resources
Section C.2. Perl Resources
Section C.3. PHP Resources
Section C.4. Python Resources
Section C.5. Java Resources
Section C.6. Apache Resources
Section C.7. Other Resources
Colophon
Index
Preface
The MySQL database management system has become quite popular in recent years. This has
been true especially in the Linux and open source communities, but MySQL's presence in the
commercial sector now is increasing as well. It is well liked for several reasons: MySQL is fast,
and it's easy to set up, use, and administrate. MySQL runs under many varieties of Unix and
Windows, and MySQL-based programs can be written in many languages. MySQL is especially
heavily used in combination with a web server for constructing database-backed web sites that
involve dynamic content generation.
With MySQL's rise in popularity comes the need to address the questions posed by its users
about how to solve specific problems. That is the purpose of MySQL Cookbook. It's designed to
serve as a handy resource to which you can turn when you need quick solutions or techniques
for attacking particular types of questions that come up when you use MySQL. Naturally,
because it's a cookbook, it contains recipes: straightforward instructions you can follow rather
than develop your own code from scratch. It's written using a problem-and-solution format
designed to be extremely practical and to make the contents easy to read and assimilate. It
contains many short sections, each describing how to write a query, apply a technique, or
develop a script to solve a problem of limited and specific scope. This book doesn't attempt to
develop full-fledged applications. Instead, it's intended to assist you in developing such
applications yourself by helping you get past problems that have you stumped.
For example, a common question is, "How can I deal with quotes and special characters in
data values when I'm writing queries?" That's not difficult, but figuring out how to do it is
frustrating when you're not sure where to start. This book demonstrates what to do; it shows
you where to begin and how to proceed from there. This knowledge will serve you repeatedly,
because after you see what's involved, you'll be able to apply the technique to any kind of
data, such as text, images, sound or video clips, news articles, compressed files, PDF files, or
word processing documents. Another common question is, "Can I access tables from two
databases at the same time?" The answer is "Yes," and it's easy to do because it's just a
matter of knowing the proper SQL syntax. But it's hard to do until you see how; this book will
show you. Other things that you'll learn from this book include:
• How to use SQL to select, sort, and summarize records.
• How to find matches or mismatches between records in two tables.
• How to perform a transaction.
• How to determine intervals between dates or times, including age calculations.
• How to remove duplicate records.
• How to store images into MySQL and retrieve them for display in web pages.
• How to convert the legal values of an ENUM column into radio buttons in a web page,
or the values of a SET column into checkboxes.
• How to get LOAD DATA to read your datafiles properly, or find out which values in the
file are bad.
• How to use pattern matching techniques to cope with mismatches between the CCYY-
MM-DD date format that MySQL uses and dates in your datafiles.
• How to copy a table or a database to another server.
• How to resequence a sequence number column, and why you really don't want to.
One part of knowing how to use MySQL is understanding how to communicate with the
server—that is, how to use SQL, the language through which queries are formulated.
Therefore, one major emphasis of this book is on using SQL to formulate queries that answer
particular kinds of questions. One helpful tool for learning and using SQL is the mysql client
program that is included in MySQL distributions. By using this client interactively, you can
send SQL statements to the server and see the results. This is extremely useful because it
provides a direct interface to SQL. The mysql client is so useful, in fact, that the entire first
chapter is devoted to it.
But the ability to issue SQL queries alone is not enough. Information extracted from a
database often needs to be processed further or presented in a particular way to be useful.
What if you have queries with complex interrelationships, such as when you need to use the
results of one query as the basis for others? SQL by itself has little facility for making these
kinds of choices, which makes it difficult to use decision-based logic to determine which
queries to execute. Or what if you need to generate a specialized report with very specific
formatting requirements? This too is difficult to achieve using just SQL. These problems bring
us to the other major emphasis of the book—how to write programs that interact with the
MySQL server through an application programming interface (API). When you know how to
use MySQL from within the context of a programming language, you gain the ability to exploit
MySQL's capabilities in the following ways:
• You can remember the result from a query and use it at a later time.
• You can make decisions based on success or failure of a query, or on the content of
the rows that are returned. Difficulties in implementing control flow disappear when
using an API because the host language provides facilities for expressing decision-
based logic: if-then-else constructs, while loops, subroutines, and so forth.
• You can format and display query results however you like. If you're writing a
command-line script, you can generate plain text. If it's a web-based script, you can
generate an HTML table. If it's an application that extracts information for transfer to
some other system, you might write a datafile expressed in XML.
When you combine SQL with a general purpose programming language and a MySQL client
API, you have an extremely flexible framework for issuing queries and processing their results.
Programming languages increase your expressive capabilities by giving you a great deal of
additional power to perform complex database operations. This doesn't mean this book is
complicated, though. It keeps things simple, showing how to construct small building blocks
by using techniques that are easy to understand and easily mastered.
I'll leave it to you to combine these techniques within your own programs, which you can do to
produce arbitrarily complex applications. After all, the genetic code is based on only four
nucleic acids, but these basic elements have been combined to produce the astonishing array
of biological life we see all around us. Similarly, there are only 12 notes in the scale, but in the
hands of skilled composers, they can be interwoven to produce a rich and endless variety of
music. In the same way, when you take a set of simple recipes, add your imagination, and
apply them to the database programming problems you want to solve, you can produce that
are perhaps not works of art, but certainly applications that are useful and that will help you
and others be more productive.
MySQL APIs Used in This Book
MySQL programming interfaces exist for many languages, including (in alphabetical order) C,
C++, Eiffel, Java, Pascal, Perl, PHP, Python, Ruby, Smalltalk, and Tcl.[]
Given this fact, writing
a MySQL cookbook presents an author with something of a challenge. Clearly the book should
provide recipes for doing many interesting and useful things with MySQL, but which API or
APIs should the book use? Showing an implementation of every recipe in every language
would result either in covering very few recipes or in a very, very large book! It would also
result in a lot of redundancy when implementations in different languages bear a strong
resemblance to each other. On the other hand, it's worthwhile taking advantage of multiple
languages, because one language often will be more suitable than another for solving a
particular type of problem.
[]
To see what APIs are currently available, visit the development portal at the
MySQL web site, located at http://www.mysql.com/portal/development/html/.
To resolve this dilemma, I've picked a small number of APIs from among those that are
available and used them to write the recipes in this book. This limits its scope to a manageable
number of APIs while allowing some latitude to choose from among them. The primary APIs
covered here are:
Perl
Using the DBI module and its MySQL-specific driver
PHP
Using its set of built-in MySQL support functions
Python
Using the DB-API module and its MySQL-specific driver
Java
Using a MySQL-specific driver for the Java Database Connectivity (JDBC) interface
Why these languages? Perl and PHP were easy to pick. Perl is arguably the most widely used
language on the Web, and it became so based on certain strengths such as its text-processing
capabilities. In particular, it's very popular for writing MySQL programs. PHP also is widely
deployed, and its use is increasing steadily. One of PHP's strengths is the ease with which you
can use it to access databases, making it a natural choice for MySQL scripting. Python and
Java are not as popular as Perl or PHP for MySQL programming, but each has significant
numbers of followers. In the Java community in particular, MySQL seems to be making strong
inroads among developers who use JavaServer Pages (JSP) technology to build database-
backed web applications. (An anecdotal observation: After I wrote MySQL (New Riders),
Python and Java were the two languages not covered in that book that readers most often
said they would have liked to have seen addressed. So here they are!)
I believe these languages taken together reflect pretty well the majority of the existing user
base of MySQL programmers. If you prefer some language not shown here, you can still use
this book, but be sure to pay careful attention to Chapter 2, to familiarize yourself with the
book's primary API languages. Knowing how database operations are performed with the APIs
used here will help you understand the recipes in later chapters so that you can translate them
into languages not discussed.
Who This Book Is For
This book should be useful for anybody who uses MySQL, ranging from novices who want to
use a database for personal reasons, to professional database and web developers. The book
should also appeal to people who do not now use MySQL, but would like to. For example, it
should be useful to beginners who want to learn about databases but realize that Oracle isn't
the best choice for that.
If you're relatively new to MySQL, you'll probably find lots of ways to use it here that you
hadn't thought of. If you're more experienced, you'll probably be familiar with many of the
problems addressed here, but you may not have had to solve them before and should find the
book a great timesaver; take advantage of the recipes given in the book and use them in your
own programs rather than figuring out how to write the code from scratch.
The book also can be useful for people who aren't even using MySQL. You might suppose that
because this is a MySQL cookbook and not a PostgreSQL cookbook or an InterBase cookbook
that it won't apply to databases other than MySQL. To some extent that's true, because some
of the SQL constructs are MySQL-specific. On the other hand, many of the queries are
standard SQL that is portable to many other database engines, so you should be able to use
them with little or no modification. And several of our programming language interfaces
provide database-independent access methods; you use them the same way regardless of
which database you're connecting to.
The material ranges from introductory to advanced, so if a recipe describes techniques that
seem obvious to you, skip it. Or if you find that you don't understand a recipe, it may be best
to set it aside for a while and come back to it later, perhaps after reading some of the
preceding recipes.
More advanced readers may wonder on occasion why in a book on MySQL I sometimes
provide explanatory material on certain basic topics that are not directly MySQL-related, such
as how to set environment variables. I decided to do this based on my experience in helping
novice MySQL users. One thing that makes MySQL attractive is that it is easy to use, which
makes it a popular choice for people without extensive background in databases. However,
many of these same people also tend to be thwarted by simple barriers to more effective use
of MySQL, as evidenced by the common question, "How can I avoid having to type the full
pathname of mysql each time I invoke it?" Experienced readers will recognize immediately
that this is simply a matter of appropriately setting the PATH environment variable to include
the directory where mysql is installed. But other readers will not, particularly Windows users
who are used to dealing only with a graphical interface and, more recently, Mac OS X users
who find their familiar user interface now augmented by the powerful but sometimes
mysterious command line provided by the Terminal application. If you are in this situation,
you'll find these more elementary sections helpful in knocking down barriers that keep you
from using MySQL more easily. If you're a more advanced user, just skip over such sections.
What's in This Book
It's very likely when you use this book that you'll have an application in mind you're trying to
develop but are not sure how to implement certain pieces of it. In this case, you'll already
know what type of problem you want to solve, so you should search the table of contents or
the index looking for a recipe that shows how to do what you want. Ideally, the recipe will be
just what you had in mind. Failing that, you should be able to find a recipe for a similar
problem that you can adapt to suit the issue at hand. (I try to explain the principles involved
in developing each technique so that you'll be able to modify it to fit the particular
requirements of your own applications.)
Another way to approach this book is to just read through it with no specific problem in mind.
This can help you because it will give you a broader understanding of the things MySQL can
do, so I recommend that you page through the book occasionally. It's a more effective tool if
you have a general familiarity with it and know the kinds of problems it addresses. The
following paragraphs summarize each chapter, to help give you an overview of the book's
contents.
Chapter 1, describes how to use the standard MySQL command-line client. mysql is often the
first interface to MySQL that people use, and it's important to know how to exploit its
capabilities. This program allows you to issue queries and see the results interactively, so it's
good for quick experimentation. You can also use it in batch mode to execute canned SQL
scripts or send its output into other programs. In addition, the chapter discusses other ways to
use mysql, such as how to number output lines or make long lines more readable, how to
generate various output formats, and how to log mysql sessions.
Chapter 2, demonstrates the basic elements of MySQL programming in each API language:
how to connect to the server, issue queries, retrieve the results, and handle errors. It also
discusses how to handle special characters and NULL values in queries, how to write library
files to encapsulate code for commonly used operations, and various ways to gather the
parameters needed for making connections to the server.
Chapter 3, covers several aspects of the SELECT statement, which is the primary vehicle for
retrieving data from the MySQL server: specifying which columns and rows you want to
retrieve, performing comparisons, dealing with NULL values, selecting one section of a query
result, using temporary tables, and copying results into other tables. Later chapters cover
some of these topics in more detail, but this chapter provides an overview of the concepts on
which they depend. You should read it if you need some introductory background on record
selection, for example, if you don't yet know a lot about SQL.
Chapter 4, describes how to deal with string data. It addresses string comparisons, pattern
matching, breaking apart and combining strings, dealing with case-sensitivity issues, and
performing FULLTEXT searches.
Chapter 5, shows how to work with temporal data. It describes MySQL's date format and how
to display date values in other formats. It also covers conversion between different temporal
units, how to perform date arithmetic to compute intervals or generate one date from another,
leap-year calculations, and how to use MySQL's special TIMESTAMP column type.
Chapter 6, describes how to put the rows of a query result in the order you want. This includes
specifying the sort direction, dealing with NULL values, accounting for string case sensitivity,
and sorting by dates or partial column values. It also provides examples that show how to sort
special kinds of values, such as domain names, IP numbers, and ENUM values.
Chapter 7, shows techniques that are useful for assessing the general characteristics of a set
of data, such as how many values it contains or what the minimum, maximum, or average
values are.
Chapter 8, describes how to alter the structure of tables by adding, dropping, or modifying
columns, and how to set up indexes.
Chapter 9, discusses how to get information about the data a query returns, such as the
number of rows or columns in the result, or the name and type of each column. It also shows
how to ask MySQL what databases and tables are available or about the structure of a table
and its columns.
Chapter 10, describes how to transfer information between MySQL and other programs. This
includes how to convert files from one format to another, extract or rearrange columns in
datafiles, check and validate data, rewrite values such as dates that often come in a variety of
formats, and how to figure out which data values cause problems when you load them into
MySQL with LOAD DATA.
Chapter 11, discusses AUTO_INCREMENT columns, MySQL's mechanism for producing
sequence numbers. It shows how to generate new sequence values or determine the most
recent value, how to resequence a column, how to begin a sequence at a given value, and
how to set up a table so that it can maintain multiple sequences at once. It also shows how to
use AUTO_INCREMENT values to maintain a master-detail relationship between tables,
including some of the pitfalls to avoid.
Chapter 12, shows how to perform joins, which are operations that combine rows in one table
with those from another. It demonstrates how to compare tables to find matches or
mismatches, produce master-detail lists and summaries, enumerate many-to-many
relationships, and update or delete records in one table based on the contents of another.
Chapter 13, illustrates how to produce descriptive statistics, frequency distributions,
regressions, and correlations. It also covers how to randomize a set of rows or pick a row at
random from the set.
Chapter 14, discusses how to identify, count, and remove duplicate records—and how to
prevent them from occurring in the first place.
Chapter 15, shows how to handle multiple SQL statements that must execute together as a
unit. It discusses how to control MySQL's auto-commit mode, how to commit or roll back
transactions, and demonstrates some workarounds you can use if transactional capabilities are
unavailable in your version of MySQL.
Chapter 16, gets you set up to write web-based MySQL scripts. Web programming allows you
to generate dynamic pages or collect information for storage in your database. The chapter
discusses how to configure Apache to run Perl, PHP, and Python scripts, and how to configure
Tomcat to run Java scripts written using JSP notation. It also provides an overview of the Java
Standard Tag Library (JSTL) that is used heavily in JSP pages in the following chapters.
Chapter 17, shows how to use the results of queries to produce various types of HTML
structures, such as paragraphs, lists, tables, hyperlinks, and navigation indexes. It also
describes how to store images into MySQL, retrieve and display them later, and how to send a
downloadable result set to a browser.
Chapter 18, discusses ways to obtain input from users over the Web and use it to create new
database records or as the basis for performing searches. It deals heavily with form
processing, including how to construct form elements, such as radio buttons, pop-up menus,
or checkboxes, based on information contained in your database.
Chapter 19, describes how to write web applications that remember information across
multiple requests, using MySQL for backing store. This is useful when you want to collect
information in stages, or when you need to make decisions based on what the user has done
earlier.
Appendix A, indicates where to get the source code for the examples shown in this book, and
where to get the software you need to use MySQL and write your own database programs.
Appendix B, provides a general overview of JSP and installation instructions for the Tomcat
web server. Read this if you need to install Tomcat or are not familiar with it, or if you're
never written JSP pages.
Appendix C, lists sources of information that provide additional information about topics
covered in this book. It also lists some books that provide introductory background for the
programming languages used here.
As you get into later chapters, you'll sometimes find recipes that assume a knowledge of
topics covered in earlier chapters. This also applies within a chapter, where later sections often
use techniques discussed earlier in the chapter. If you jump into a chapter and find a recipe
that uses a technique with which you're not familiar, check the table of contents or the index
to find out where the technique is covered. You should find that it's been explained earlier. For
example, if you find that a recipe sorts a query result using an ORDER BY clause that you don't
understand, turn to Chapter 6, which discusses various sorting methods and explains how
they work.
Platform Notes
Development of the code in this book took place under MySQL 3.23 and 4.0. Because new
features are added to MySQL on a regular basis, some examples will not work under older
versions. I've tried to point out version dependencies when introducing such features for the
first time.
The MySQL language API modules that I used include DBI 1.20 and up, DBD::mysql 2.0901
and up, MySQLdb 0.9 and up, MM.MySQL 2.0.5 and up, and MySQL Connector/J 2.0.14. DBI
requires Perl 5.004_05 or higher up through DBI 1.20, after which it requires Perl 5.005_03 or
higher. MySQLdb requires Python 1.5.6 or higher. MM.MySQL and MySQL Connector/J require
Java SDK 1.1 or higher.
Language processors include Perl 5.6 and 5.6.1; PHP 3 and 4; Python 1.5.6, 2.2; and 2.3, and
Java SDK 1.3.1. Most PHP scripts shown here will run under either PHP 3 or PHP 4 (although I
strongly recommend PHP 4 over PHP 3). Scripts that require PHP 4 are so noted.
I do not assume that you are using Unix, although that is my own preferred development
platform. Most of the material here should be applicable both to Unix and Windows. The
operating systems I used most for development of the recipes in this book were Mac OS X;
RedHat Linux 6.2, 7.0, and 7.3; and various versions of Windows (Me, 98, NT, and 2000).
I do assume that MySQL is installed already and available for you to use. I also assume that if
you plan to write your own MySQL-based programs, you're reasonably familiar with the
language you'll use. If you need to install software, see Appendix A. If you require background
material on the programming languages used here, see Appendix C.
Discovering Diverse Content Through
Random Scribd Documents
MySQL Cookbook 1st ed Edition Paul Dubois
MySQL Cookbook 1st ed Edition Paul Dubois
The Project Gutenberg eBook of Gay-Neck
This ebook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this ebook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.
Title: Gay-Neck
The story of a pigeon
Author: Dhan Gopal Mukerji
Illustrator: Boris Artzybasheff
Release date: November 10, 2023 [eBook #72086]
Language: English
Original publication: New York, NY: E.P. Dutton & Co., Inc, 1927
Credits: Greg Weeks, Mary Meehan and the Online Distributed
Proofreading Team at http://www.pgdp.net
*** START OF THE PROJECT GUTENBERG EBOOK GAY-NECK ***
Gay-Neck
Copyright, 1927
By E. P. DUTTON & COMPANY
All rights reserved
First Printing July, 1927
Fifth Printing Dec., 1927
Tenth Printing May, 1928
Fifteenth Printing Oct., 1928
Seventeenth Printing Jan., 1929
Eighteenth Printing June, 1929
Nineteenth Printing Nov., 1929
Twentieth Printing Nov., 1929
Printed in the United States of America
This book was awarded the
John Newbery Medal by the
Children's Librarians' Section of
the American Library
Association, for the most
distinguished contribution to
American Children's literature
during the year 1927.
By the same author
CASTE AND OUTCAST
MY BROTHER'S FACE
THE SECRET LISTENERS OF THE EAST
THE FACE OF SILENCE
Stories for Children
KARI THE ELEPHANT
JUNGLE BEASTS AND MEN
HARI THE JUNGLE LAD
GAY-NECK (The Story of a Pigeon)
Published by
E. P. DUTTON & CO., INC.
TO
Dear Suresh:
Since Gay-Neck needs a protector I thought of you for several
reasons. First of all being a poet, an observer of nature, and a
traveller, you would be able to protect the book from being
condemned. In fact, there is no one who can do it as well as yourself.
You know the country where Gay-Neck grew. You are versed in the
lore of birds. For a pigeon, life is a repetition of two incidents: namely,
quest of food and avoidance of attacks by its enemies. If the hero of
the present book repeats his escapes from attacks by hawks, it is
because that is the sort of mishap that becomes chronic in the case
of pigeons.
Now as to my sources, you well know that they are too numerous to
be mentioned here. Many hunters, poets like yourself, and books in
many languages have helped me to write Gay-Neck. And if you will
permit it, I hope to discharge at least a part of my debt by dedicating
this book to one of my sources—yourself.
I remain most faithfully yours,
Dhan Gopal.
CONTENTS
PART I
I. Birth of Gay-Neck
II Education of Gay-Neck
III. Training in Direction
IV. Gay-Neck in the Himalayas
V. On Gay-Neck's Track
VI. Gay-Neck's Truancy
VII. Gay-Neck's Story
VIII. Gay-Neck's Odyssey (Continued)
PART II
I. Gay-Neck's Training for War
II. War Training (Continued)
III. Mating of Gay-Neck
IV. War Calls Gay-Neck
V. Second Adventure
VI. Ghond Goes Reconnoitring
VII. Gay-Neck Tells How He Carried the Message
VIII. Healing of Hate and Fear
IX. The Wisdom of the Lama
LIST OF ILLUSTRATIONS
Gay-Neck
With Enormously Long Reach He almost Touched the Top of
the Tree
No Beast of Prey Can Kill His Victim without Frightening Him
First
That Sound was Drowned in the Cry of the Eagles above
Who Screeched Like Mad, Slaying Each Other
GAY-NECK
MySQL Cookbook 1st ed Edition Paul Dubois
PART I
CHAPTER I
BIRTH OF GAY-NECK
he city of Calcutta, which boasts of a million
people, must have at least two million pigeons.
Every third Hindu boy has perhaps a dozen pet
carriers, tumblers, fantails, and pouters. The art of
domesticating pigeons goes back thousands of
years in India, and she has contributed two species
of pigeons as a special product of her bird fanciers,
the fantail and the pouter. Love and care have
been showered on pigeons for centuries by emperors, princes and
queens in their marble palaces, as well as by the poor, in their
humble homes. The gardens, grottos and fountains of the Indian rich
—the small field of flowers and fruits of the common folks, each has
its ornament and music,—many-colored pigeons and cooing white
doves with ruby eyes.
Even now any winter morning foreigners who visit our big cities may
see on the flat-roofed houses innumerable boys waving white flags
as signals to their pet pigeons flying up in the crisp cold air. Through
the blue heavens flocks of the birds soar like vast clouds. They start
in small flocks and spend about twenty minutes circling over the
roofs of their owners' homes. Then they slowly ascend and all the
separate groups from different houses of the town merge into one
big flock and float far out of sight. How they ever return to their own
homes is a wonder, for all the house-tops look alike in shape in spite
of their rose, yellow, violet and white colors.
But pigeons have an amazing sense of direction and love of their
owners. I have yet to see creatures more loyal than pigeons and
elephants. I have played with both, and the tusker on four feet in the
country, or the bird on two wings in the city, no matter how far they
wandered, were by their almost infallible instinct brought back to
their friend and brother—Man.
My elephant friend was called Kari, of whom you have heard before,
and the other pet that I knew well was a pigeon. His name was
Chitra-griva; Chitra meaning painted in gay colours, and Griva, neck
—in one phrase, pigeon Gay-Neck. Sometimes he was called
"Iridescence-throated."
Of course Gay-Neck did not come out of his egg with an iridescent
throat; he had to grow the feathers week by week; and until he was
three months old, there was very little hope that he would acquire the
brilliant collar, but at last when he did achieve it, he was the most
beautiful pigeon in my town in India, and the boys of my town owned
forty thousand pigeons.
But I must begin this story at the very beginning, I mean with Gay-
Neck's parents. His father was a tumbler who married the most
beautiful pigeon of his day; she came from a noble old stock of
carriers. That is why Gay-Neck proved himself later such a worthy
carrier pigeon in war as well as in peace. From his mother he
inherited wisdom, from his father bravery and alertness. He was so
quick-witted that sometimes he escaped the clutches of a hawk by
tumbling at the last moment right over the enemy's head. But of that
later, in its proper time and place.
Now let me tell you what a narrow escape Gay-Neck had while still in
the egg. I shall never forget the day when, through a mistake of
mine, I broke one of the two eggs that his mother had laid. It was
very stupid of me. I regret it even now. Who knows, maybe with that
broken egg perished the finest pigeon of the world. It happened in
this way. Our house was four stories high—and on its roof was built
our pigeon house. A few days after the eggs were laid I decided to
clean the pigeon hole in which Gay-Neck's mother was sitting on
them. I lifted her gently and put her on the roof beside me. Then I
lifted each egg carefully and put it most softly in the next pigeon
hole; which however had no cotton nor flannel on its hard wooden
floor. Then I busied myself with the task of removing the debris from
the birth-nest. As soon as that was done, I brought one egg back
and restored it to its proper place. Next I reached for the second one
and laid a gentle but firm hand on it. Just then something fell upon
my face like a roof blown by the storm. It was Gay-Neck's father
furiously beating my face with his wings. Worse still, he had placed
the claws of one of his feet on my nose. The pain and surprise of it
was so great that ere I knew how, I had dropped the egg. I was
engrossed in beating off the bird from my head and face and at last
he flew away. But too late; the little egg lay broken in a mess at my
feet. I was furious with its clumsy father and also with myself. Why
with myself? Because I should have been prepared for the father
bird's attack. He took me for a stealer of his eggs, and in his
ignorance was risking his life to prevent my robbing his nest. May I
impress it upon you that you should anticipate all kinds of surprise
attacks when cleaning a bird's home during nesting season.
But to go on with our story. The mother bird knew the day when she
was to break open the egg-shell with her own beak, in order to usher
Gay-Neck into the world. Though the male sits on the egg pretty
nearly one third of the time—for he does that each day from morning
till late afternoon—yet he does not know when the hour of his child's
birth is at hand. No one save the mother bird arrives at that divine
certainty. We do not yet understand the nature of the unique wireless
message by which she learns that within the shell the yolk and the
white of her egg have turned into a baby-bird. She also knows how
to tap the right spot so that the shell will break open without injuring
her child in the slightest. To me that is as good as a miracle.
Gay-Neck's birth happened exactly as I have described. About the
twentieth day after the laying of the egg I noticed that the mother
was not sitting on it any more. She pecked the father and drove him
away every time he flew down from the roof of the house and
volunteered to sit on the egg. Then he cooed, which meant, "Why do
you send me away?"
She, the mother, just pecked him the more, meaning, "Please go.
The business on hand is very serious."
At that, the father flew away. That worried me, for I was anxious for
the egg to hatch, and was feeling suspicious about its doing it at all.
With increased interest and anxiety I watched the pigeon hole. An
hour passed. Nothing happened. It was about the third quarter of the
next hour that the mother turned her head one way and listened to
something—probably a stirring inside that egg. Then she gave a
slight start. I felt as if a tremor were running through her whole body.
With it a great resolution came into her. Now she raised her head,
and took aim. In two strokes she cracked the egg open, revealing a
wee bird, all beak and a tiny shivering body! Now watch the mother.
She is surprised. Was it this that she was expecting all these long
days? Oh, how small, how helpless! The moment she realizes her
child's helplessness, she covers him up with the soft blue feathers of
her breast.
CHAPTER II
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookfinal.com

More Related Content

PDF
MySQL Cookbook 1st ed Edition Paul Dubois
PDF
MySQL Cookbook 1st ed Edition Paul Dubois
PDF
Mysql Cookbook Solutions For Database Developers And Administrators Dubois
PDF
0888 learning-mysql
PDF
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
PDF
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
PDF
MySQL Notes For Professionals sttudy.pdf
PDF
Learning Mysql Seyed Mm Saied Tahaghoghi Hugh Williams
MySQL Cookbook 1st ed Edition Paul Dubois
MySQL Cookbook 1st ed Edition Paul Dubois
Mysql Cookbook Solutions For Database Developers And Administrators Dubois
0888 learning-mysql
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
Mysql Cookbook Solutions For Database Developers And Administrators 4th Editi...
MySQL Notes For Professionals sttudy.pdf
Learning Mysql Seyed Mm Saied Tahaghoghi Hugh Williams

Similar to MySQL Cookbook 1st ed Edition Paul Dubois (20)

PDF
MySQL notes for professionals
PDF
Mysql notes for professionals
PDF
Mysql In A Nutshell In A Nutshell Oreilly Second Edition Russell Dyer
PPT
My sql with querys
PPT
MySql slides (ppt)
PPTX
Lecture2 mysql by okello erick
PPT
Mysql Fun
 
PDF
MySQL for beginners
PPTX
Lecture3 mysql gui by okello erick
PPTX
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
PPTX
Introduction databases and MYSQL
PPTX
PHP mysql Introduction database
PDF
PDF
Mysql basics1
PPTX
MSAvMySQL.pptx
PPT
Mysqlppt3510
PPT
Mysqlppt3510
PPTX
MySQL Essential Training
PPTX
Using Mysql.pptx
MySQL notes for professionals
Mysql notes for professionals
Mysql In A Nutshell In A Nutshell Oreilly Second Edition Russell Dyer
My sql with querys
MySql slides (ppt)
Lecture2 mysql by okello erick
Mysql Fun
 
MySQL for beginners
Lecture3 mysql gui by okello erick
DATA BASE || INTRODUCTION OF DATABASE \\ SQL 2018
Introduction databases and MYSQL
PHP mysql Introduction database
Mysql basics1
MSAvMySQL.pptx
Mysqlppt3510
Mysqlppt3510
MySQL Essential Training
Using Mysql.pptx
Ad

Recently uploaded (20)

PDF
Complications of Minimal Access Surgery at WLH
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Institutional Correction lecture only . . .
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
master seminar digital applications in india
PDF
Insiders guide to clinical Medicine.pdf
PPTX
GDM (1) (1).pptx small presentation for students
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Classroom Observation Tools for Teachers
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Computing-Curriculum for Schools in Ghana
Complications of Minimal Access Surgery at WLH
2.FourierTransform-ShortQuestionswithAnswers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Institutional Correction lecture only . . .
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Cell Types and Its function , kingdom of life
Microbial disease of the cardiovascular and lymphatic systems
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
master seminar digital applications in india
Insiders guide to clinical Medicine.pdf
GDM (1) (1).pptx small presentation for students
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Final Presentation General Medicine 03-08-2024.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Classroom Observation Tools for Teachers
STATICS OF THE RIGID BODIES Hibbelers.pdf
O7-L3 Supply Chain Operations - ICLT Program
Computing-Curriculum for Schools in Ghana
Ad

MySQL Cookbook 1st ed Edition Paul Dubois

  • 1. Visit ebookfinal.com to download the full version and explore more ebooks or textbooks MySQL Cookbook 1st ed Edition Paul Dubois _____ Click the link below to download _____ https://ebookfinal.com/download/mysql-cookbook-1st-ed- edition-paul-dubois/ Explore and download more ebooks or textbook at ebookfinal.com
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. MySQL Cookbook 2nd Edition Solutions Examples for Database Developers and DBAs Paul Dubois https://ebookfinal.com/download/mysql-cookbook-2nd-edition-solutions- examples-for-database-developers-and-dbas-paul-dubois/ MySQL Admin Cookbook 1st New edition Edition Daniel Schneller https://ebookfinal.com/download/mysql-admin-cookbook-1st-new-edition- edition-daniel-schneller/ MySQL Cookbook 4th Edition Sveta Smirnova & Alkin Tezuysal https://ebookfinal.com/download/mysql-cookbook-4th-edition-sveta- smirnova-alkin-tezuysal/ Useful Quasicrystals 1st Edition Jean-Marie Dubois https://ebookfinal.com/download/useful-quasicrystals-1st-edition-jean- marie-dubois/
  • 3. Python Cookbook 2nd ed Edition Alex Martelli https://ebookfinal.com/download/python-cookbook-2nd-ed-edition-alex- martelli/ Linux Security Cookbook 1st ed Edition Daniel J. Barrett https://ebookfinal.com/download/linux-security-cookbook-1st-ed- edition-daniel-j-barrett/ Access Data Analysis Cookbook 1st ed Edition Ken Bluttman https://ebookfinal.com/download/access-data-analysis-cookbook-1st-ed- edition-ken-bluttman/ Analog Circuits Cookbook 2nd ed Edition Ian Hickman https://ebookfinal.com/download/analog-circuits-cookbook-2nd-ed- edition-ian-hickman/ MySQL Crash Course Rick Silva https://ebookfinal.com/download/mysql-crash-course-rick-silva/
  • 5. MySQL Cookbook 1st ed Edition Paul Dubois Digital Instant Download Author(s): Paul DuBois ISBN(s): 9780596001452, 0596001452 Edition: 1st ed File Details: PDF, 4.00 MB Year: 2003 Language: english
  • 6. MySQL Cookbook By Paul DuBois Publisher : O'Reilly Pub Date : October 2002
  • 7. ISBN : 0-596-00145-2 Pages : 1022 MySQL Cookbook provides a unique problem-and-solution format that offers practical examples for everyday programming dilemmas. For every problem addressed in the book, there's a worked-out solution or "recipe" -- short, focused pieces of code that you can insert directly into your applications. More than a collection of cut-and-paste code, this book explanation how and why the code works, so you can learn to adapt the techniques to similar situations.
  • 8. Copyright Preface MySQL APIs Used in This Book Who This Book Is For What's in This Book Platform Notes Conventions Used in This Book The Companion Web Site Comments and Questions Additional Resources Acknowledgments Chapter 1. Using the mysql Client Program Section 1.1. Introduction Section 1.2. Setting Up a MySQL User Account Section 1.3. Creating a Database and a Sample Table Section 1.4. Starting and Terminating mysql Section 1.5. Specifying Connection Parameters by Using Option Files Section 1.6. Protecting Option Files Section 1.7. Mixing Command-Line and Option File Parameters Section 1.8. What to Do if mysql Cannot Be Found Section 1.9. Setting Environment Variables Section 1.10. Issuing Queries Section 1.11. Selecting a Database Section 1.12. Canceling a Partially Entered Query Section 1.13. Repeating and Editing Queries Section 1.14. Using Auto-Completion for Database and Table Names Section 1.15. Using SQL Variables in Queries Section 1.16. Telling mysql to Read Queries from a File Section 1.17. Telling mysql to Read Queries from Other Programs Section 1.18. Specifying Queries on the Command Line Section 1.19. Using Copy and Paste as a mysql Input Source Section 1.20. Preventing Query Output from Scrolling off the Screen Section 1.21. Sending Query Output to a File or to a Program Section 1.22. Selecting Tabular or Tab-Delimited Query Output Format Section 1.23. Specifying Arbitrary Output Column Delimiters Section 1.24. Producing HTML Output Section 1.25. Producing XML Output Section 1.26. Suppressing Column Headings in Query Output Section 1.27. Numbering Query Output Lines Section 1.28. Making Long Output Lines More Readable Section 1.29. Controlling mysql's Verbosity Level Section 1.30. Logging Interactive mysql Sessions
  • 9. Section 1.31. Creating mysql Scripts from Previously Executed Queries Section 1.32. Using mysql as a Calculator Section 1.33. Using mysql in Shell Scripts Chapter 2. Writing MySQL-Based Programs Section 2.1. Introduction Section 2.2. Connecting to the MySQL Server, Selecting a Database, and Disconnecting Section 2.3. Checking for Errors Section 2.4. Writing Library Files Section 2.5. Issuing Queries and Retrieving Results Section 2.6. Moving Around Within a Result Set Section 2.7. Using Prepared Statements and Placeholders in Queries Section 2.8. Including Special Characters and NULL Values in Queries Section 2.9. Handling NULL Values in Result Sets Section 2.10. Writing an Object-Oriented MySQL Interface for PHP Section 2.11. Ways of Obtaining Connection Parameters Section 2.12. Conclusion and Words of Advice Chapter 3. Record Selection Techniques Section 3.1. Introduction Section 3.2. Specifying Which Columns to Display Section 3.3. Avoiding Output Column Order Problems When Writing Programs Section 3.4. Giving Names to Output Columns Section 3.5. Using Column Aliases to Make Programs Easier to Write Section 3.6. Combining Columns to Construct Composite Values Section 3.7. Specifying Which Rows to Select Section 3.8. WHERE Clauses and Column Aliases Section 3.9. Displaying Comparisons to Find Out How Something Works Section 3.10. Reversing or Negating Query Conditions Section 3.11. Removing Duplicate Rows Section 3.12. Working with NULL Values Section 3.13. Negating a Condition on a Column That Contains NULL Values Section 3.14. Writing Comparisons Involving NULL in Programs Section 3.15. Mapping NULL Values to Other Values for Display Section 3.16. Sorting a Result Set Section 3.17. Selecting Records from the Beginning or End of a Result Set Section 3.18. Pulling a Section from the Middle of a Result Set Section 3.19. Choosing Appropriate LIMIT Values Section 3.20. Calculating LIMIT Values from Expressions Section 3.21. What to Do When LIMIT Requires the "Wrong" Sort Order Section 3.22. Selecting a Result Set into an Existing Table Section 3.23. Creating a Destination Table on the Fly from a Result Set Section 3.24. Moving Records Between Tables Safely
  • 10. Section 3.25. Creating Temporary Tables Section 3.26. Cloning a Table Exactly Section 3.27. Generating Unique Table Names Chapter 4. Working with Strings Section 4.1. Introduction Section 4.2. Writing Strings That Include Quotes or Special Characters Section 4.3. Preserving Trailing Spaces in String Columns Section 4.4. Testing String Equality or Relative Ordering Section 4.5. Decomposing or Combining Strings Section 4.6. Checking Whether a String Contains a Substring Section 4.7. Pattern Matching with SQL Patterns Section 4.8. Pattern Matching with Regular Expressions Section 4.9. Matching Pattern Metacharacters Literally Section 4.10. Controlling Case Sensitivity in String Comparisons Section 4.11. Controlling Case Sensitivity in Pattern Matching Section 4.12. Using FULLTEXT Searches Section 4.13. Using a FULLTEXT Search with Short Words Section 4.14. Requiring or Excluding FULLTEXT Search Words Section 4.15. Performing Phrase Searches with a FULLTEXT Index Chapter 5. Working with Dates and Times Section 5.1. Introduction Section 5.2. Changing MySQL's Date Format Section 5.3. Telling MySQL How to Display Dates or Times Section 5.4. Determining the Current Date or Time Section 5.5. Decomposing Dates and Times Using Formatting Functions Section 5.6. Decomposing Dates or Times Using Component-Extraction Functions Section 5.7. Decomposing Dates or Times Using String Functions Section 5.8. Synthesizing Dates or Times Using Formatting Functions Section 5.9. Synthesizing Dates or Times Using Component-Extraction Functions Section 5.10. Combining a Date and a Time into a Date-and-Time Value Section 5.11. Converting Between Times and Seconds Section 5.12. Converting Between Dates and Days Section 5.13. Converting Between Date-and-Time Values and Seconds Section 5.14. Adding a Temporal Interval to a Time Section 5.15. Calculating Intervals Between Times Section 5.16. Breaking Down Time Intervals into Components Section 5.17. Adding a Temporal Interval to a Date Section 5.18. Calculating Intervals Between Dates Section 5.19. Canonizing Not-Quite-ISO Date Strings Section 5.20. Calculating Ages Section 5.21. Shifting Dates by a Known Amount
  • 11. Section 5.22. Finding First and Last Days of Months Section 5.23. Finding the Length of a Month Section 5.24. Calculating One Date from Another by Substring Replacement Section 5.25. Finding the Day of the Week for a Date Section 5.26. Finding Dates for Days of the Current Week Section 5.27. Finding Dates for Weekdays of Other Weeks Section 5.28. Performing Leap Year Calculations Section 5.29. Treating Dates or Times as Numbers Section 5.30. Forcing MySQL to Treat Strings as Temporal Values Section 5.31. Selecting Records Based on Their Temporal Characteristics Section 5.32. Using TIMESTAMP Values Section 5.33. Recording a Row's Last Modification Time Section 5.34. Recording a Row's Creation Time Section 5.35. Performing Calculations with TIMESTAMP Values Section 5.36. Displaying TIMESTAMP Values in Readable Form Chapter 6. Sorting Query Results Section 6.1. Introduction Section 6.2. Using ORDER BY to Sort Query Results Section 6.3. Sorting Subsets of a Table Section 6.4. Sorting Expression Results Section 6.5. Displaying One Set of Values While Sorting by Another Section 6.6. Sorting and NULL Values Section 6.7. Controlling Case Sensitivity of String Sorts Section 6.8. Date-Based Sorting Section 6.9. Sorting by Calendar Day Section 6.10. Sorting by Day of Week Section 6.11. Sorting by Time of Day Section 6.12. Sorting Using Substrings of Column Values Section 6.13. Sorting by Fixed-Length Substrings Section 6.14. Sorting by Variable-Length Substrings Section 6.15. Sorting Hostnames in Domain Order Section 6.16. Sorting Dotted-Quad IP Values in Numeric Order Section 6.17. Floating Specific Values to the Head or Tail of the Sort Order Section 6.18. Sorting in User-Defined Orders Section 6.19. Sorting ENUM Values Chapter 7. Generating Summaries Section 7.1. Introduction Section 7.2. Summarizing with COUNT( ) Section 7.3. Summarizing with MIN( ) and MAX( ) Section 7.4. Summarizing with SUM( ) and AVG( ) Section 7.5. Using DISTINCT to Eliminate Duplicates
  • 12. Section 7.6. Finding Values Associated with Minimum and Maximum Values Section 7.7. Controlling String Case Sensitivity for MIN( ) and MAX( ) Section 7.8. Dividing a Summary into Subgroups Section 7.9. Summaries and NULL Values Section 7.10. Selecting Only Groups with Certain Characteristics Section 7.11. Determining Whether Values are Unique Section 7.12. Grouping by Expression Results Section 7.13. Categorizing Non-Categorical Data Section 7.14. Controlling Summary Display Order Section 7.15. Finding Smallest or Largest Summary Values Section 7.16. Date-Based Summaries Section 7.17. Working with Per-Group and Overall Summary Values Simultaneously Section 7.18. Generating a Report That Includes a Summary and a List Chapter 8. Modifying Tables with ALTER TABLE Section 8.1. Introduction Section 8.2. Dropping, Adding, or Repositioning a Column Section 8.3. Changing a Column Definition or Name Section 8.4. The Effect of ALTER TABLE on Null and Default Value Attributes Section 8.5. Changing a Column's Default Value Section 8.6. Changing a Table Type Section 8.7. Renaming a Table Section 8.8. Adding or Dropping Indexes Section 8.9. Eliminating Duplicates by Adding an Index Section 8.10. Using ALTER TABLE to Normalize a Table Chapter 9. Obtaining and Using Metadata Section 9.1. Introduction Section 9.2. Obtaining the Number of Rows Affected by a Query Section 9.3. Obtaining Result Set Metadata Section 9.4. Determining Presence or Absence of a Result Set Section 9.5. Formatting Query Results for Display Section 9.6. Getting Table Structure Information Section 9.7. Getting ENUM and SET Column Information Section 9.8. Database-Independent Methods of Obtaining Table Information Section 9.9. Applying Table Structure Information Section 9.10. Listing Tables and Databases Section 9.11. Testing Whether a Table Exists Section 9.12. Testing Whether a Database Exists Section 9.13. Getting Server Metadata Section 9.14. Writing Applications That Adapt to the MySQL Server Version Section 9.15. Determining the Current Database Section 9.16. Determining the Current MySQL User
  • 13. Section 9.17. Monitoring the MySQL Server Section 9.18. Determining Which Table Types the Server Supports Chapter 10. Importing and Exporting Data Section 10.1. Introduction Section 10.2. Importing Data with LOAD DATA and mysqlimport Section 10.3. Specifying the Datafile Location Section 10.4. Specifying the Datafile Format Section 10.5. Dealing with Quotes and Special Characters Section 10.6. Importing CSV Files Section 10.7. Reading Files from Different Operating Systems Section 10.8. Handling Duplicate Index Values Section 10.9. Getting LOAD DATA to Cough Up More Information Section 10.10. Don't Assume LOAD DATA Knows More than It Does Section 10.11. Skipping Datafile Lines Section 10.12. Specifying Input Column Order Section 10.13. Skipping Datafile Columns Section 10.14. Exporting Query Results from MySQL Section 10.15. Exporting Tables as Raw Data Section 10.16. Exporting Table Contents or Definitions in SQL Format Section 10.17. Copying Tables or Databases to Another Server Section 10.18. Writing Your Own Export Programs Section 10.19. Converting Datafiles from One Format to Another Section 10.20. Extracting and Rearranging Datafile Columns Section 10.21. Validating and Transforming Data Section 10.22. Validation by Direct Comparison Section 10.23. Validation by Pattern Matching Section 10.24. Using Patterns to Match Broad Content Types Section 10.25. Using Patterns to Match Numeric Values Section 10.26. Using Patterns to Match Dates or Times Section 10.27. Using Patterns to Match Email Addresses and URLs Section 10.28. Validation Using Table Metadata Section 10.29. Validation Using a Lookup Table Section 10.30. Converting Two-Digit Year Values to Four-Digit Form Section 10.31. Performing Validity Checking on Date or Time Subparts Section 10.32. Writing Date-Processing Utilities Section 10.33. Using Dates with Missing Components Section 10.34. Performing Date Conversion Using SQL Section 10.35. Using Temporary Tables for Data Transformation Section 10.36. Dealing with NULL Values Section 10.37. Guessing Table Structure from a Datafile Section 10.38. A LOAD DATA Diagnostic Utility Section 10.39. Exchanging Data Between MySQL and Microsoft Access
  • 14. Section 10.40. Exchanging Data Between MySQL and Microsoft Excel Section 10.41. Exchanging Data Between MySQL and FileMaker Pro Section 10.42. Exporting Query Results as XML Section 10.43. Importing XML into MySQL Section 10.44. Epilog Chapter 11. Generating and Using Sequences Section 11.1. Introduction Section 11.2. Using AUTO_INCREMENT To Set Up a Sequence Column Section 11.3. Generating Sequence Values Section 11.4. Choosing the Type for a Sequence Column Section 11.5. The Effect of Record Deletions on Sequence Generation Section 11.6. Retrieving Sequence Values Section 11.7. Determining Whether to Resequence a Column Section 11.8. Extending the Range of a Sequence Column Section 11.9. Renumbering an Existing Sequence Section 11.10. Reusing Values at the Top of a Sequence Section 11.11. Ensuring That Rows Are Renumbered in a Particular Order Section 11.12. Starting a Sequence at a Particular Value Section 11.13. Sequencing an Unsequenced Table Section 11.14. Using an AUTO_INCREMENT Column to Create Multiple Sequences Section 11.15. Managing Multiple SimultaneousAUTO_INCREMENT Values Section 11.16. Using AUTO_INCREMENT Valuesto Relate Tables Section 11.17. Using Single-Row Sequence Generators Section 11.18. Generating Repeating Sequences Section 11.19. Numbering Query Output Rows Sequentially Chapter 12. Using Multiple Tables Section 12.1. Introduction Section 12.2. Combining Rows in One Table with Rows in Another Section 12.3. Performing a Join Between Tables in Different Databases Section 12.4. Referring to Join Output Column Names in Programs Section 12.5. Finding Rows in One Table That Match Rows in Another Section 12.6. Finding Rows with No Match in Another Table Section 12.7. Finding Rows Containing Per-Group Minimum or Maximum Values Section 12.8. Computing Team Standings Section 12.9. Producing Master-Detail Lists and Summaries Section 12.10. Using a Join to Fill in Holes in a List Section 12.11. Enumerating a Many-to-Many Relationship Section 12.12. Comparing a Table to Itself Section 12.13. Calculating Differences Between Successive Rows Section 12.14. Finding Cumulative Sums and Running Averages Section 12.15. Using a Join to Control Query Output Order
  • 15. Section 12.16. Converting Subselects to Join Operations Section 12.17. Selecting Records in Parallel from Multiple Tables Section 12.18. Inserting Records in One Table That Include Values from Another Section 12.19. Updating One Table Based on Values in Another Section 12.20. Using a Join to Create a Lookup Table from Descriptive Labels Section 12.21. Deleting Related Rows in Multiple Tables Section 12.22. Identifying and Removing Unattached Records Section 12.23. Using Different MySQL Servers Simultaneously Chapter 13. Statistical Techniques Section 13.1. Introduction Section 13.2. Calculating Descriptive Statistics Section 13.3. Per-Group Descriptive Statistics Section 13.4. Generating Frequency Distributions Section 13.5. Counting Missing Values Section 13.6. Calculating Linear Regressions or Correlation Coefficients Section 13.7. Generating Random Numbers Section 13.8. Randomizing a Set of Rows Section 13.9. Selecting Random Items from a Set of Rows Section 13.10. Assigning Ranks Chapter 14. Handling Duplicates Section 14.1. Introduction Section 14.2. Preventing Duplicates from Occurring in a Table Section 14.3. Dealing with Duplicates at Record-Creation Time Section 14.4. Counting and Identifying Duplicates Section 14.5. Eliminating Duplicates from a Query Result Section 14.6. Eliminating Duplicates from a Self-Join Result Section 14.7. Eliminating Duplicates from a Table Chapter 15. Performing Transactions Section 15.1. Introduction Section 15.2. Verifying Transaction Support Requirements Section 15.3. Performing Transactions Using SQL Section 15.4. Performing Transactions from Within Programs Section 15.5. Using Transactions in Perl Programs Section 15.6. Using Transactions in PHP Programs Section 15.7. Using Transactions in Python Programs Section 15.8. Using Transactions in Java Programs Section 15.9. Using Alternatives to Transactions Chapter 16. Introduction to MySQL on the Web Section 16.1. Introduction
  • 16. Section 16.2. Basic Web Page Generation Section 16.3. Using Apache to Run Web Scripts Section 16.4. Using Tomcat to Run Web Scripts Section 16.5. Encoding Special Characters in Web Output Chapter 17. Incorporating Query Resultsinto Web Pages Section 17.1. Introduction Section 17.2. Displaying Query Results as Paragraph Text Section 17.3. Displaying Query Results as Lists Section 17.4. Displaying Query Results as Tables Section 17.5. Displaying Query Results as Hyperlinks Section 17.6. Creating a Navigation Index from Database Content Section 17.7. Storing Images or Other Binary Data Section 17.8. Retrieving Images or Other Binary Data Section 17.9. Serving Banner Ads Section 17.10. Serving Query Results for Download Chapter 18. Processing Web Input with MySQL Section 18.1. Introduction Section 18.2. Creating Forms in Scripts Section 18.3. Creating Single-Pick Form Elements from Database Content Section 18.4. Creating Multiple-Pick Form Elements from Database Content Section 18.5. Loading a Database Record into a Form Section 18.6. Collecting Web Input Section 18.7. Validating Web Input Section 18.8. Using Web Input to Construct Queries Section 18.9. Processing File Uploads Section 18.10. Performing Searches and Presenting the Results Section 18.11. Generating Previous-Page and Next-Page Links Section 18.12. Generating "Click to Sort" Table Headings Section 18.13. Web Page Access Counting Section 18.14. Web Page Access Logging Section 18.15. Using MySQL for Apache Logging Chapter 19. Using MySQL-Based Web Session Management Section 19.1. Introduction Section 19.2. Using MySQL-Based Sessions in Perl Applications Section 19.3. Using MySQL-Based Storage with the PHP Session Manager Section 19.4. Using MySQL for Session BackingStore with Tomcat Appendix A. Obtaining MySQL Software Section A.1. Obtaining Sample Source Code and Data Section A.2. Obtaining MySQL and Related Software
  • 17. Appendix B. JSP and Tomcat Primer Section B.1. Servlet and JavaServer Pages Overview Section B.2. Setting Up a Tomcat Server Section B.3. Web Application Structure Section B.4. Elements of JSP Pages Appendix C. References Section C.1. MySQL Resources Section C.2. Perl Resources Section C.3. PHP Resources Section C.4. Python Resources Section C.5. Java Resources Section C.6. Apache Resources Section C.7. Other Resources Colophon Index
  • 18. Preface The MySQL database management system has become quite popular in recent years. This has been true especially in the Linux and open source communities, but MySQL's presence in the commercial sector now is increasing as well. It is well liked for several reasons: MySQL is fast, and it's easy to set up, use, and administrate. MySQL runs under many varieties of Unix and Windows, and MySQL-based programs can be written in many languages. MySQL is especially heavily used in combination with a web server for constructing database-backed web sites that involve dynamic content generation. With MySQL's rise in popularity comes the need to address the questions posed by its users about how to solve specific problems. That is the purpose of MySQL Cookbook. It's designed to serve as a handy resource to which you can turn when you need quick solutions or techniques for attacking particular types of questions that come up when you use MySQL. Naturally, because it's a cookbook, it contains recipes: straightforward instructions you can follow rather than develop your own code from scratch. It's written using a problem-and-solution format designed to be extremely practical and to make the contents easy to read and assimilate. It contains many short sections, each describing how to write a query, apply a technique, or develop a script to solve a problem of limited and specific scope. This book doesn't attempt to develop full-fledged applications. Instead, it's intended to assist you in developing such applications yourself by helping you get past problems that have you stumped. For example, a common question is, "How can I deal with quotes and special characters in data values when I'm writing queries?" That's not difficult, but figuring out how to do it is frustrating when you're not sure where to start. This book demonstrates what to do; it shows you where to begin and how to proceed from there. This knowledge will serve you repeatedly, because after you see what's involved, you'll be able to apply the technique to any kind of data, such as text, images, sound or video clips, news articles, compressed files, PDF files, or word processing documents. Another common question is, "Can I access tables from two databases at the same time?" The answer is "Yes," and it's easy to do because it's just a matter of knowing the proper SQL syntax. But it's hard to do until you see how; this book will show you. Other things that you'll learn from this book include: • How to use SQL to select, sort, and summarize records. • How to find matches or mismatches between records in two tables. • How to perform a transaction. • How to determine intervals between dates or times, including age calculations. • How to remove duplicate records. • How to store images into MySQL and retrieve them for display in web pages. • How to convert the legal values of an ENUM column into radio buttons in a web page, or the values of a SET column into checkboxes. • How to get LOAD DATA to read your datafiles properly, or find out which values in the file are bad.
  • 19. • How to use pattern matching techniques to cope with mismatches between the CCYY- MM-DD date format that MySQL uses and dates in your datafiles. • How to copy a table or a database to another server. • How to resequence a sequence number column, and why you really don't want to. One part of knowing how to use MySQL is understanding how to communicate with the server—that is, how to use SQL, the language through which queries are formulated. Therefore, one major emphasis of this book is on using SQL to formulate queries that answer particular kinds of questions. One helpful tool for learning and using SQL is the mysql client program that is included in MySQL distributions. By using this client interactively, you can send SQL statements to the server and see the results. This is extremely useful because it provides a direct interface to SQL. The mysql client is so useful, in fact, that the entire first chapter is devoted to it. But the ability to issue SQL queries alone is not enough. Information extracted from a database often needs to be processed further or presented in a particular way to be useful. What if you have queries with complex interrelationships, such as when you need to use the results of one query as the basis for others? SQL by itself has little facility for making these kinds of choices, which makes it difficult to use decision-based logic to determine which queries to execute. Or what if you need to generate a specialized report with very specific formatting requirements? This too is difficult to achieve using just SQL. These problems bring us to the other major emphasis of the book—how to write programs that interact with the MySQL server through an application programming interface (API). When you know how to use MySQL from within the context of a programming language, you gain the ability to exploit MySQL's capabilities in the following ways: • You can remember the result from a query and use it at a later time. • You can make decisions based on success or failure of a query, or on the content of the rows that are returned. Difficulties in implementing control flow disappear when using an API because the host language provides facilities for expressing decision- based logic: if-then-else constructs, while loops, subroutines, and so forth. • You can format and display query results however you like. If you're writing a command-line script, you can generate plain text. If it's a web-based script, you can generate an HTML table. If it's an application that extracts information for transfer to some other system, you might write a datafile expressed in XML. When you combine SQL with a general purpose programming language and a MySQL client API, you have an extremely flexible framework for issuing queries and processing their results. Programming languages increase your expressive capabilities by giving you a great deal of additional power to perform complex database operations. This doesn't mean this book is complicated, though. It keeps things simple, showing how to construct small building blocks by using techniques that are easy to understand and easily mastered. I'll leave it to you to combine these techniques within your own programs, which you can do to produce arbitrarily complex applications. After all, the genetic code is based on only four
  • 20. nucleic acids, but these basic elements have been combined to produce the astonishing array of biological life we see all around us. Similarly, there are only 12 notes in the scale, but in the hands of skilled composers, they can be interwoven to produce a rich and endless variety of music. In the same way, when you take a set of simple recipes, add your imagination, and apply them to the database programming problems you want to solve, you can produce that are perhaps not works of art, but certainly applications that are useful and that will help you and others be more productive. MySQL APIs Used in This Book MySQL programming interfaces exist for many languages, including (in alphabetical order) C, C++, Eiffel, Java, Pascal, Perl, PHP, Python, Ruby, Smalltalk, and Tcl.[] Given this fact, writing a MySQL cookbook presents an author with something of a challenge. Clearly the book should provide recipes for doing many interesting and useful things with MySQL, but which API or APIs should the book use? Showing an implementation of every recipe in every language would result either in covering very few recipes or in a very, very large book! It would also result in a lot of redundancy when implementations in different languages bear a strong resemblance to each other. On the other hand, it's worthwhile taking advantage of multiple languages, because one language often will be more suitable than another for solving a particular type of problem. [] To see what APIs are currently available, visit the development portal at the MySQL web site, located at http://www.mysql.com/portal/development/html/. To resolve this dilemma, I've picked a small number of APIs from among those that are available and used them to write the recipes in this book. This limits its scope to a manageable number of APIs while allowing some latitude to choose from among them. The primary APIs covered here are: Perl Using the DBI module and its MySQL-specific driver PHP Using its set of built-in MySQL support functions Python Using the DB-API module and its MySQL-specific driver Java Using a MySQL-specific driver for the Java Database Connectivity (JDBC) interface Why these languages? Perl and PHP were easy to pick. Perl is arguably the most widely used language on the Web, and it became so based on certain strengths such as its text-processing
  • 21. capabilities. In particular, it's very popular for writing MySQL programs. PHP also is widely deployed, and its use is increasing steadily. One of PHP's strengths is the ease with which you can use it to access databases, making it a natural choice for MySQL scripting. Python and Java are not as popular as Perl or PHP for MySQL programming, but each has significant numbers of followers. In the Java community in particular, MySQL seems to be making strong inroads among developers who use JavaServer Pages (JSP) technology to build database- backed web applications. (An anecdotal observation: After I wrote MySQL (New Riders), Python and Java were the two languages not covered in that book that readers most often said they would have liked to have seen addressed. So here they are!) I believe these languages taken together reflect pretty well the majority of the existing user base of MySQL programmers. If you prefer some language not shown here, you can still use this book, but be sure to pay careful attention to Chapter 2, to familiarize yourself with the book's primary API languages. Knowing how database operations are performed with the APIs used here will help you understand the recipes in later chapters so that you can translate them into languages not discussed. Who This Book Is For This book should be useful for anybody who uses MySQL, ranging from novices who want to use a database for personal reasons, to professional database and web developers. The book should also appeal to people who do not now use MySQL, but would like to. For example, it should be useful to beginners who want to learn about databases but realize that Oracle isn't the best choice for that. If you're relatively new to MySQL, you'll probably find lots of ways to use it here that you hadn't thought of. If you're more experienced, you'll probably be familiar with many of the problems addressed here, but you may not have had to solve them before and should find the book a great timesaver; take advantage of the recipes given in the book and use them in your own programs rather than figuring out how to write the code from scratch. The book also can be useful for people who aren't even using MySQL. You might suppose that because this is a MySQL cookbook and not a PostgreSQL cookbook or an InterBase cookbook that it won't apply to databases other than MySQL. To some extent that's true, because some of the SQL constructs are MySQL-specific. On the other hand, many of the queries are standard SQL that is portable to many other database engines, so you should be able to use them with little or no modification. And several of our programming language interfaces provide database-independent access methods; you use them the same way regardless of which database you're connecting to. The material ranges from introductory to advanced, so if a recipe describes techniques that seem obvious to you, skip it. Or if you find that you don't understand a recipe, it may be best to set it aside for a while and come back to it later, perhaps after reading some of the preceding recipes.
  • 22. More advanced readers may wonder on occasion why in a book on MySQL I sometimes provide explanatory material on certain basic topics that are not directly MySQL-related, such as how to set environment variables. I decided to do this based on my experience in helping novice MySQL users. One thing that makes MySQL attractive is that it is easy to use, which makes it a popular choice for people without extensive background in databases. However, many of these same people also tend to be thwarted by simple barriers to more effective use of MySQL, as evidenced by the common question, "How can I avoid having to type the full pathname of mysql each time I invoke it?" Experienced readers will recognize immediately that this is simply a matter of appropriately setting the PATH environment variable to include the directory where mysql is installed. But other readers will not, particularly Windows users who are used to dealing only with a graphical interface and, more recently, Mac OS X users who find their familiar user interface now augmented by the powerful but sometimes mysterious command line provided by the Terminal application. If you are in this situation, you'll find these more elementary sections helpful in knocking down barriers that keep you from using MySQL more easily. If you're a more advanced user, just skip over such sections. What's in This Book It's very likely when you use this book that you'll have an application in mind you're trying to develop but are not sure how to implement certain pieces of it. In this case, you'll already know what type of problem you want to solve, so you should search the table of contents or the index looking for a recipe that shows how to do what you want. Ideally, the recipe will be just what you had in mind. Failing that, you should be able to find a recipe for a similar problem that you can adapt to suit the issue at hand. (I try to explain the principles involved in developing each technique so that you'll be able to modify it to fit the particular requirements of your own applications.) Another way to approach this book is to just read through it with no specific problem in mind. This can help you because it will give you a broader understanding of the things MySQL can do, so I recommend that you page through the book occasionally. It's a more effective tool if you have a general familiarity with it and know the kinds of problems it addresses. The following paragraphs summarize each chapter, to help give you an overview of the book's contents. Chapter 1, describes how to use the standard MySQL command-line client. mysql is often the first interface to MySQL that people use, and it's important to know how to exploit its capabilities. This program allows you to issue queries and see the results interactively, so it's good for quick experimentation. You can also use it in batch mode to execute canned SQL scripts or send its output into other programs. In addition, the chapter discusses other ways to use mysql, such as how to number output lines or make long lines more readable, how to generate various output formats, and how to log mysql sessions. Chapter 2, demonstrates the basic elements of MySQL programming in each API language: how to connect to the server, issue queries, retrieve the results, and handle errors. It also discusses how to handle special characters and NULL values in queries, how to write library
  • 23. files to encapsulate code for commonly used operations, and various ways to gather the parameters needed for making connections to the server. Chapter 3, covers several aspects of the SELECT statement, which is the primary vehicle for retrieving data from the MySQL server: specifying which columns and rows you want to retrieve, performing comparisons, dealing with NULL values, selecting one section of a query result, using temporary tables, and copying results into other tables. Later chapters cover some of these topics in more detail, but this chapter provides an overview of the concepts on which they depend. You should read it if you need some introductory background on record selection, for example, if you don't yet know a lot about SQL. Chapter 4, describes how to deal with string data. It addresses string comparisons, pattern matching, breaking apart and combining strings, dealing with case-sensitivity issues, and performing FULLTEXT searches. Chapter 5, shows how to work with temporal data. It describes MySQL's date format and how to display date values in other formats. It also covers conversion between different temporal units, how to perform date arithmetic to compute intervals or generate one date from another, leap-year calculations, and how to use MySQL's special TIMESTAMP column type. Chapter 6, describes how to put the rows of a query result in the order you want. This includes specifying the sort direction, dealing with NULL values, accounting for string case sensitivity, and sorting by dates or partial column values. It also provides examples that show how to sort special kinds of values, such as domain names, IP numbers, and ENUM values. Chapter 7, shows techniques that are useful for assessing the general characteristics of a set of data, such as how many values it contains or what the minimum, maximum, or average values are. Chapter 8, describes how to alter the structure of tables by adding, dropping, or modifying columns, and how to set up indexes. Chapter 9, discusses how to get information about the data a query returns, such as the number of rows or columns in the result, or the name and type of each column. It also shows how to ask MySQL what databases and tables are available or about the structure of a table and its columns. Chapter 10, describes how to transfer information between MySQL and other programs. This includes how to convert files from one format to another, extract or rearrange columns in datafiles, check and validate data, rewrite values such as dates that often come in a variety of formats, and how to figure out which data values cause problems when you load them into MySQL with LOAD DATA. Chapter 11, discusses AUTO_INCREMENT columns, MySQL's mechanism for producing sequence numbers. It shows how to generate new sequence values or determine the most
  • 24. recent value, how to resequence a column, how to begin a sequence at a given value, and how to set up a table so that it can maintain multiple sequences at once. It also shows how to use AUTO_INCREMENT values to maintain a master-detail relationship between tables, including some of the pitfalls to avoid. Chapter 12, shows how to perform joins, which are operations that combine rows in one table with those from another. It demonstrates how to compare tables to find matches or mismatches, produce master-detail lists and summaries, enumerate many-to-many relationships, and update or delete records in one table based on the contents of another. Chapter 13, illustrates how to produce descriptive statistics, frequency distributions, regressions, and correlations. It also covers how to randomize a set of rows or pick a row at random from the set. Chapter 14, discusses how to identify, count, and remove duplicate records—and how to prevent them from occurring in the first place. Chapter 15, shows how to handle multiple SQL statements that must execute together as a unit. It discusses how to control MySQL's auto-commit mode, how to commit or roll back transactions, and demonstrates some workarounds you can use if transactional capabilities are unavailable in your version of MySQL. Chapter 16, gets you set up to write web-based MySQL scripts. Web programming allows you to generate dynamic pages or collect information for storage in your database. The chapter discusses how to configure Apache to run Perl, PHP, and Python scripts, and how to configure Tomcat to run Java scripts written using JSP notation. It also provides an overview of the Java Standard Tag Library (JSTL) that is used heavily in JSP pages in the following chapters. Chapter 17, shows how to use the results of queries to produce various types of HTML structures, such as paragraphs, lists, tables, hyperlinks, and navigation indexes. It also describes how to store images into MySQL, retrieve and display them later, and how to send a downloadable result set to a browser. Chapter 18, discusses ways to obtain input from users over the Web and use it to create new database records or as the basis for performing searches. It deals heavily with form processing, including how to construct form elements, such as radio buttons, pop-up menus, or checkboxes, based on information contained in your database. Chapter 19, describes how to write web applications that remember information across multiple requests, using MySQL for backing store. This is useful when you want to collect information in stages, or when you need to make decisions based on what the user has done earlier. Appendix A, indicates where to get the source code for the examples shown in this book, and where to get the software you need to use MySQL and write your own database programs.
  • 25. Appendix B, provides a general overview of JSP and installation instructions for the Tomcat web server. Read this if you need to install Tomcat or are not familiar with it, or if you're never written JSP pages. Appendix C, lists sources of information that provide additional information about topics covered in this book. It also lists some books that provide introductory background for the programming languages used here. As you get into later chapters, you'll sometimes find recipes that assume a knowledge of topics covered in earlier chapters. This also applies within a chapter, where later sections often use techniques discussed earlier in the chapter. If you jump into a chapter and find a recipe that uses a technique with which you're not familiar, check the table of contents or the index to find out where the technique is covered. You should find that it's been explained earlier. For example, if you find that a recipe sorts a query result using an ORDER BY clause that you don't understand, turn to Chapter 6, which discusses various sorting methods and explains how they work. Platform Notes Development of the code in this book took place under MySQL 3.23 and 4.0. Because new features are added to MySQL on a regular basis, some examples will not work under older versions. I've tried to point out version dependencies when introducing such features for the first time. The MySQL language API modules that I used include DBI 1.20 and up, DBD::mysql 2.0901 and up, MySQLdb 0.9 and up, MM.MySQL 2.0.5 and up, and MySQL Connector/J 2.0.14. DBI requires Perl 5.004_05 or higher up through DBI 1.20, after which it requires Perl 5.005_03 or higher. MySQLdb requires Python 1.5.6 or higher. MM.MySQL and MySQL Connector/J require Java SDK 1.1 or higher. Language processors include Perl 5.6 and 5.6.1; PHP 3 and 4; Python 1.5.6, 2.2; and 2.3, and Java SDK 1.3.1. Most PHP scripts shown here will run under either PHP 3 or PHP 4 (although I strongly recommend PHP 4 over PHP 3). Scripts that require PHP 4 are so noted. I do not assume that you are using Unix, although that is my own preferred development platform. Most of the material here should be applicable both to Unix and Windows. The operating systems I used most for development of the recipes in this book were Mac OS X; RedHat Linux 6.2, 7.0, and 7.3; and various versions of Windows (Me, 98, NT, and 2000). I do assume that MySQL is installed already and available for you to use. I also assume that if you plan to write your own MySQL-based programs, you're reasonably familiar with the language you'll use. If you need to install software, see Appendix A. If you require background material on the programming languages used here, see Appendix C.
  • 26. Discovering Diverse Content Through Random Scribd Documents
  • 29. The Project Gutenberg eBook of Gay-Neck
  • 30. This ebook is for the use of anyone anywhere in the United States and most other parts of the world at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this ebook or online at www.gutenberg.org. If you are not located in the United States, you will have to check the laws of the country where you are located before using this eBook. Title: Gay-Neck The story of a pigeon Author: Dhan Gopal Mukerji Illustrator: Boris Artzybasheff Release date: November 10, 2023 [eBook #72086] Language: English Original publication: New York, NY: E.P. Dutton & Co., Inc, 1927 Credits: Greg Weeks, Mary Meehan and the Online Distributed Proofreading Team at http://www.pgdp.net *** START OF THE PROJECT GUTENBERG EBOOK GAY-NECK ***
  • 32. Copyright, 1927 By E. P. DUTTON & COMPANY All rights reserved First Printing July, 1927 Fifth Printing Dec., 1927 Tenth Printing May, 1928 Fifteenth Printing Oct., 1928 Seventeenth Printing Jan., 1929
  • 33. Eighteenth Printing June, 1929 Nineteenth Printing Nov., 1929 Twentieth Printing Nov., 1929 Printed in the United States of America This book was awarded the John Newbery Medal by the Children's Librarians' Section of the American Library Association, for the most distinguished contribution to American Children's literature during the year 1927. By the same author CASTE AND OUTCAST MY BROTHER'S FACE THE SECRET LISTENERS OF THE EAST THE FACE OF SILENCE
  • 34. Stories for Children KARI THE ELEPHANT JUNGLE BEASTS AND MEN HARI THE JUNGLE LAD GAY-NECK (The Story of a Pigeon) Published by E. P. DUTTON & CO., INC.
  • 35. TO Dear Suresh: Since Gay-Neck needs a protector I thought of you for several reasons. First of all being a poet, an observer of nature, and a traveller, you would be able to protect the book from being condemned. In fact, there is no one who can do it as well as yourself. You know the country where Gay-Neck grew. You are versed in the lore of birds. For a pigeon, life is a repetition of two incidents: namely, quest of food and avoidance of attacks by its enemies. If the hero of the present book repeats his escapes from attacks by hawks, it is because that is the sort of mishap that becomes chronic in the case of pigeons. Now as to my sources, you well know that they are too numerous to be mentioned here. Many hunters, poets like yourself, and books in many languages have helped me to write Gay-Neck. And if you will permit it, I hope to discharge at least a part of my debt by dedicating this book to one of my sources—yourself. I remain most faithfully yours, Dhan Gopal.
  • 36. CONTENTS PART I I. Birth of Gay-Neck II Education of Gay-Neck III. Training in Direction IV. Gay-Neck in the Himalayas V. On Gay-Neck's Track VI. Gay-Neck's Truancy VII. Gay-Neck's Story VIII. Gay-Neck's Odyssey (Continued) PART II I. Gay-Neck's Training for War II. War Training (Continued) III. Mating of Gay-Neck IV. War Calls Gay-Neck V. Second Adventure VI. Ghond Goes Reconnoitring VII. Gay-Neck Tells How He Carried the Message VIII. Healing of Hate and Fear IX. The Wisdom of the Lama
  • 37. LIST OF ILLUSTRATIONS Gay-Neck With Enormously Long Reach He almost Touched the Top of the Tree No Beast of Prey Can Kill His Victim without Frightening Him First That Sound was Drowned in the Cry of the Eagles above Who Screeched Like Mad, Slaying Each Other
  • 42. BIRTH OF GAY-NECK he city of Calcutta, which boasts of a million people, must have at least two million pigeons. Every third Hindu boy has perhaps a dozen pet carriers, tumblers, fantails, and pouters. The art of domesticating pigeons goes back thousands of years in India, and she has contributed two species of pigeons as a special product of her bird fanciers, the fantail and the pouter. Love and care have been showered on pigeons for centuries by emperors, princes and queens in their marble palaces, as well as by the poor, in their humble homes. The gardens, grottos and fountains of the Indian rich —the small field of flowers and fruits of the common folks, each has its ornament and music,—many-colored pigeons and cooing white doves with ruby eyes. Even now any winter morning foreigners who visit our big cities may see on the flat-roofed houses innumerable boys waving white flags as signals to their pet pigeons flying up in the crisp cold air. Through the blue heavens flocks of the birds soar like vast clouds. They start in small flocks and spend about twenty minutes circling over the roofs of their owners' homes. Then they slowly ascend and all the separate groups from different houses of the town merge into one big flock and float far out of sight. How they ever return to their own homes is a wonder, for all the house-tops look alike in shape in spite of their rose, yellow, violet and white colors. But pigeons have an amazing sense of direction and love of their owners. I have yet to see creatures more loyal than pigeons and elephants. I have played with both, and the tusker on four feet in the country, or the bird on two wings in the city, no matter how far they wandered, were by their almost infallible instinct brought back to their friend and brother—Man.
  • 43. My elephant friend was called Kari, of whom you have heard before, and the other pet that I knew well was a pigeon. His name was Chitra-griva; Chitra meaning painted in gay colours, and Griva, neck —in one phrase, pigeon Gay-Neck. Sometimes he was called "Iridescence-throated." Of course Gay-Neck did not come out of his egg with an iridescent throat; he had to grow the feathers week by week; and until he was three months old, there was very little hope that he would acquire the brilliant collar, but at last when he did achieve it, he was the most beautiful pigeon in my town in India, and the boys of my town owned forty thousand pigeons. But I must begin this story at the very beginning, I mean with Gay- Neck's parents. His father was a tumbler who married the most beautiful pigeon of his day; she came from a noble old stock of carriers. That is why Gay-Neck proved himself later such a worthy carrier pigeon in war as well as in peace. From his mother he inherited wisdom, from his father bravery and alertness. He was so quick-witted that sometimes he escaped the clutches of a hawk by tumbling at the last moment right over the enemy's head. But of that later, in its proper time and place. Now let me tell you what a narrow escape Gay-Neck had while still in the egg. I shall never forget the day when, through a mistake of mine, I broke one of the two eggs that his mother had laid. It was very stupid of me. I regret it even now. Who knows, maybe with that broken egg perished the finest pigeon of the world. It happened in this way. Our house was four stories high—and on its roof was built our pigeon house. A few days after the eggs were laid I decided to clean the pigeon hole in which Gay-Neck's mother was sitting on them. I lifted her gently and put her on the roof beside me. Then I lifted each egg carefully and put it most softly in the next pigeon hole; which however had no cotton nor flannel on its hard wooden floor. Then I busied myself with the task of removing the debris from the birth-nest. As soon as that was done, I brought one egg back and restored it to its proper place. Next I reached for the second one and laid a gentle but firm hand on it. Just then something fell upon my face like a roof blown by the storm. It was Gay-Neck's father
  • 44. furiously beating my face with his wings. Worse still, he had placed the claws of one of his feet on my nose. The pain and surprise of it was so great that ere I knew how, I had dropped the egg. I was engrossed in beating off the bird from my head and face and at last he flew away. But too late; the little egg lay broken in a mess at my feet. I was furious with its clumsy father and also with myself. Why with myself? Because I should have been prepared for the father bird's attack. He took me for a stealer of his eggs, and in his ignorance was risking his life to prevent my robbing his nest. May I impress it upon you that you should anticipate all kinds of surprise attacks when cleaning a bird's home during nesting season. But to go on with our story. The mother bird knew the day when she was to break open the egg-shell with her own beak, in order to usher Gay-Neck into the world. Though the male sits on the egg pretty nearly one third of the time—for he does that each day from morning till late afternoon—yet he does not know when the hour of his child's birth is at hand. No one save the mother bird arrives at that divine certainty. We do not yet understand the nature of the unique wireless message by which she learns that within the shell the yolk and the white of her egg have turned into a baby-bird. She also knows how to tap the right spot so that the shell will break open without injuring her child in the slightest. To me that is as good as a miracle. Gay-Neck's birth happened exactly as I have described. About the twentieth day after the laying of the egg I noticed that the mother was not sitting on it any more. She pecked the father and drove him away every time he flew down from the roof of the house and volunteered to sit on the egg. Then he cooed, which meant, "Why do you send me away?" She, the mother, just pecked him the more, meaning, "Please go. The business on hand is very serious." At that, the father flew away. That worried me, for I was anxious for the egg to hatch, and was feeling suspicious about its doing it at all. With increased interest and anxiety I watched the pigeon hole. An hour passed. Nothing happened. It was about the third quarter of the next hour that the mother turned her head one way and listened to
  • 45. something—probably a stirring inside that egg. Then she gave a slight start. I felt as if a tremor were running through her whole body. With it a great resolution came into her. Now she raised her head, and took aim. In two strokes she cracked the egg open, revealing a wee bird, all beak and a tiny shivering body! Now watch the mother. She is surprised. Was it this that she was expecting all these long days? Oh, how small, how helpless! The moment she realizes her child's helplessness, she covers him up with the soft blue feathers of her breast.
  • 47. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookfinal.com