100% found this document useful (5 votes)
69 views

Instant download Getting Started with SQL and Databases: Managing and Manipulating Data with SQL Mark Simon pdf all chapter

Manipulating

Uploaded by

trinnnerhot
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
69 views

Instant download Getting Started with SQL and Databases: Managing and Manipulating Data with SQL Mark Simon pdf all chapter

Manipulating

Uploaded by

trinnnerhot
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 66

Download Full Version ebookmass - Visit ebookmass.

com

Getting Started with SQL and Databases: Managing


and Manipulating Data with SQL Mark Simon

https://ebookmass.com/product/getting-started-with-sql-and-
databases-managing-and-manipulating-data-with-sql-mark-
simon/

OR CLICK HERE

DOWLOAD NOW

Discover More Ebook - Explore Now at ebookmass.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Getting Started with SQL and Databases: Managing and


Manipulating Data with SQL 1st Edition Mark Simon

https://ebookmass.com/product/getting-started-with-sql-and-databases-
managing-and-manipulating-data-with-sql-1st-edition-mark-simon/

ebookmass.com

Leveling Up with SQL: Advanced Techniques for Transforming


Data into Insights Mark Simon

https://ebookmass.com/product/leveling-up-with-sql-advanced-
techniques-for-transforming-data-into-insights-mark-simon/

ebookmass.com

Programming Arduino: Getting Started with Sketches, Third


Edition Simon Monk

https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-third-edition-simon-monk/

ebookmass.com

Vatican II: A Very Short Introduction Blanchard

https://ebookmass.com/product/vatican-ii-a-very-short-introduction-
blanchard/

ebookmass.com
Nonconventional and Vernacular Construction Materials■
Characterisation, Properties and Applications Kent A.
Harries & Bhavna Sharma
https://ebookmass.com/product/nonconventional-and-vernacular-
construction-materials%ef%bc%9a-characterisation-properties-and-
applications-kent-a-harries-bhavna-sharma/
ebookmass.com

Golden Hill Francis Spufford

https://ebookmass.com/product/golden-hill-francis-spufford/

ebookmass.com

The Last List of Miss Judith Kratt 1st Edition Andrea


Bobotis

https://ebookmass.com/product/the-last-list-of-miss-judith-kratt-1st-
edition-andrea-bobotis/

ebookmass.com

Information Systems Today: Managing the Digital World 8t,


global Edition Joseph Valacich

https://ebookmass.com/product/information-systems-today-managing-the-
digital-world-8t-global-edition-joseph-valacich/

ebookmass.com

Curriculum: From Theory to Practice 2nd Edition

https://ebookmass.com/product/curriculum-from-theory-to-practice-2nd-
edition/

ebookmass.com
Exploratory Data Analysis Using R 1st Edition Ronald K.
Pearson

https://ebookmass.com/product/exploratory-data-analysis-using-r-1st-
edition-ronald-k-pearson/

ebookmass.com
Mark Simon

Getting Started with SQL and Databases


Managing and Manipulating Data with SQL
Mark Simon
Ivanhoe VIC, VIC, Australia

ISBN 978-1-4842-9492-5 e-ISBN 978-1-4842-9493-2


https://doi.org/10.1007/978-1-4842-9493-2

© Mark Simon 2023

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors, and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

This Apress imprint is published by the registered company APress


Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
To Sachiko. Thanks for your patience, forbearance, and trust.
Introduction
In the distant past, data was managed by computers in all sorts of ways,
and there was no one way to do this. There still isn’t, which isn’t a bad
thing, because not all data can be handled the same way. There is,
however, a large body of data which can be handled in a common way,
and the early 1970s saw the development of a set of mathematical
principles in the relational model.
Starting in a lab at IBM, software was developed to handle relational
data, and a language was developed to manage it. The language
eventually became the Structured Query Language. In the early days,
different vendors had their own idea of how the language should work,
but this was eventually rolled into a standard. The standard has grown
over the decades, which means that the language is also growing.
Not all database vendors follow the standard to the same degree.
Some standards were late in coming, and database vendors filled in
some gaps with their imagination. Other standards are harder to
implement than it looks, and some vendors are “still working on it.” And
sometimes, the vendor just wants to do something differently.
This book looks at using SQL for basic tasks. Mostly that means
fetching data and possibly processing it. There are many database
packages available, all with their own quirks, and all with their own
variations of the SQL standard. This book covers a few of the most
popular packages and makes a point of showing not only what the
standard says but also how the individual packages do things.
We’ll also look at how databases are designed, but not because we’ll
be designing any. One of the big mysteries to any new SQL user is why
do we do things this way or that, and why is the data the way it is. By
understanding some design principles, you’ll be in a better position to
know why.
In this book, we make no assumptions about your prior knowledge,
except that you have an idea what a table is. You have probably had
some experience with spreadsheets as well.
As to what you might do afterward, that depends. It might be your
job to fetch data to feed it into some sort of analysis or reporting
software. You might do all of your analysis in SQL directly, or you might
write queries in a specialized database application. Or you might be a
web developer looking to manage a blog or an ecommerce site.

The Sample Data


We’ll talk more about the sample data later in the book, but the book is
based on a sample database. You can sit in an armchair and read the
book as it is if you like, but you’ll probably want to work through the
exercises.
To work through the exercises, you’ll need the following:
A database server and a suitable database client.
Permissions to do anything you like on the database. If you’ve
installed the software locally, you probably have all the permissions
you need, but if you’re doing this on somebody else’s system, you
need to check.
The script which produces the sample database.
You can get a fresh copy of the script from
https://sample-db.net
and choose your options.
If that’s too much like hard work, you can use the following links to
download a script:
PostgreSQL: https://sample-db.net/?dbmss[]=pgsql-
10&db=prints&br=crlf&refresh&download
SQLite: https://sample-db.net?dbmss[]=sqlite-
script&db=prints&br=crlf&refresh&download
MySQL/MariaDB: https://sample-db.net/?
dbmss[]=mysql-
ansi&db=prints&br=crlf&refresh&download
Microsoft SQL: https://sample-db.net/?dbmss[]=mssql-
16&db=prints&br=crlf&refresh&download
Oracle: https://sample-db.net/?dbmss[]=oracle-
12&db=prints&br=crlf&refresh&download
These links are for current versions of the software. If you want
older versions, visit the preceding site.
Notes
Throughout the book, you’ll come across a few terms and a few
expectations:
MySQL and MariaDB are essentially the same; MariaDB is an
increasingly popular spin-off. With very few exceptions (as noted),
the code is interchangeable.
The book makes a great deal of using MySQL/MariaDB in so-called
ANSI mode. This is easily done, as you’ll see in the book, and makes
working with standard SQL much easier.
The Microsoft product will sometimes be referred to as Microsoft
SQL Server and sometimes as MSSQL for short. If you’re looking for
T-SQL (Transact SQL), it’s also the same thing.
Any source code or other supplementary material referenced by the
author in this book is available to readers on GitHub. For more detailed
information, please visit http://www.apress.com/source-code.
Acknowledgments
The sample data includes information about classical paintings and
their artists. This information is an extract of the hard work that went
into the WebMuseum (www.ibiblio.org/wm/).
Table of Contents
Chapter 1:​Starting with SQL
Basic SELECT Statement
Case Sensitivity
Spacing
Clause Ordering
The Semicolon (;)
Selecting Specific Columns
Column Order
Layout
Using SELECT *
Calculated Columns
Aliases
Comments
Block Comments
Uses of Comments
Filtering Rows
Clause Ordering
Placing the Semicolon
Ordering the Results
Clause Order
Distinct Rows
Summary
Writing SQL
Columns
Comments
Filtering Data
Row Order
Clause Order
Coming Up
Chapter 2:​Database
About the Sample Database
Database
Tables
Normalized Tables
Multiple Values
Summary
Coming Up
Chapter 3:​Filtering Data
The WHERE Clause
Unrelated Assertions
All and Nothing
Dealing with NULL
Deliberately Ignoring NULLs
Finding NULLs
Numbers
Discrete vs.​Continuous Values
Strings
Quotes
More on MySQL/​MariaDB Modes
More on Double and Single Quotes
Case Sensitivity
Trailing Spaces
Filtering with String Functions
Handling Quotes and Apostrophes
Before and After Strings
Dates
Dates Are Not Strings
Alternative Date Formats
Date Comparisons
Filtering with a Date Calculation
Multiple Assertions
AND and OR
The IN Operator
Derived Lists
Wildcard Matches
Case Sensitivity and Patterns
Pattern Characters
Wildcards with Non-strings
Extensions to Wildcards
A Simple Pattern Match Example
Summary
NULL
Numbers
Strings
Dates
Multiple Assertions
The IN Operator
Wildcard Matches
Coming Up
Chapter 4:​Ordering Results
Using the ORDER BY Clause
Sort Direction
Missing Data (NULL)
Data Types
Case Sensitivity and Collation
Multiple Columns
Interdependence of Columns
Sort Direction on Multiple Columns
Sorting by Calculated Columns
Limiting the Number of Results
Paging
Using LIMIT … OFFSET … (MySQL/​MariaDB, SQLite, and
PostgreSQL)
Using TOP (MSSQL)
Fetching a Random Row
Nonalphabetical String Order
Special Strings
Summary
Sorting with ORDER BY
Limiting Results
Sorting Strings
Coming Up
Chapter 5:​Calculating Column Values
Testing Calculations
Emulating Variables
Some Basic Calculations
Basic Number Calculations
Basic String Calculations
Basic Date Calculations
Working with NULL
Using Aliases
Aliases Without AS
Awkward Aliases
Calculating with Numbers
Arithmetic Operators
Integers
Remainder
Extra Decimals
Mathematical Functions
Approximation Functions
Formatting Functions
Calculating with Dates
Simple Calculations
Age Calculations
Extracting Parts of a Date
Formatting a Date
Strings
Character Functions
Subqueries
The CASE Expression
Casting to Different Data Types
The cast( ) Function
Casting to a String
Casting Date Literals
Creating a View
Using Views in Microsoft SQL
Summary
Data Types
NULLs
Aliases
Subqueries
The CASE Expression
Casting a Value
Views
Coming Up
Chapter 6:​Joining Tables
How a Join Works
Joining the Tables
Alternative Syntax
Selecting the Results
Table Aliases
Developing a Price List
Join Types
The INNER JOIN
The LEFT OUTER JOIN and RIGHT OUTER JOIN
The “Preferred” Outer Join
Some Recommendations on JOINS
Finishing the Price List
Joining Many Tables
Building a Larger JOIN
Revisiting Some Subqueries
A More Complex Join
Using a Self-Join
Summary
Syntax
Table Aliases
The ON Clause
Join Types
Coming Up
Chapter 7:​Aggregating Data
Counting Data
Counting Values
How Aggregates Work
Counting Selectively
Distinct Values
Summarizing Numbers
Bad Examples
Scales of Measurement
Aggregating Calculated Data
Other Aggregate Functions
Using Aggregates As Filters
Grouping
Using the GROUP BY Clause
GROUP BY vs.​DISTINCT
Grouping with Multiple Tables
Redundant Groups
Preparing Data for Aggregating
Using CASE in a CTE
Using a Join in the CTE
Summarizing Strings
Filtering Grouped Results with HAVING
Using Results in a CTE
Finding Duplicates
Using Aggregates on Aggregates
Summary
Coming Up
Chapter 8:​Working with Tables
How Tables Are Created
Creating a Table
Column Names
Data Type
Primary Keys
Constraints
NOT NULL
UNIQUE
DEFAULT
CHECK
Foreign Keys
Indexes
Adding Rows to a Table
Deleting Rows from a Table
Adding More Rows
Updating Rows
Altering the Table
DML in Real Life
Security
Front-End Software
Summary
Data Types
Constraints
Foreign Keys
Indexes
Manipulating Data
Chapter 9:​Set Operations
Unions
Selective Unions
SELECT Clauses Must Be Compatible
Only Column Names from the First SELECT Statement Are
Used
Sorting Results
Intersections
Differences
Some Tricks with Set Operations
Comparing Results
Virtual Tables
Mixing Aggregates
Summary
Appendix 1:​Differences Between SQL Dialects
Appendix 2:​A Crash Course in PDO
Appendix 3:​Additional Notes
Index
About the Author
Mark Simon
has been involved in training and
education since the beginning of his
career. He started as a teacher of
mathematics but soon moved into IT
consultancy and training because
computers are much easier to work with
than high school students. He has
worked with and trained in several
programming and coding languages and
currently focuses mainly on web
development and database languages.
When not involved in work, you will
generally find him listening to or playing
music, reading, or just wandering about.
About the Technical Reviewer
Atul Tyagi
is a database developer who has worked
extensively in the field of data analytics
for over eight years. He has worked with
various industries, including general
insurance and banking domains, and has
contributed significantly to several
projects involving reporting, datamarts,
automation, data model development,
and project migration.
Atul is skilled in SQL, SAS, Python,
and ETL tools such as Informatica, SAS
DI, Datastage, and SAS Visual Analytics.
His expertise in these areas has helped
numerous organizations effectively
manage and analyze their data, leading
to improved decision-making and business outcomes. Atul has worked
with leading companies such as Accenture Solutions, Wipro Pvt Ltd,
Acxiom Technologies, and EXL Services.
Apart from his professional work, Atul is also passionate about
sharing his knowledge, cloud platforms, and data analytics. In his free
time, he enjoys reading, traveling, and exploring new cuisines.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer
Nature 2023
M. Simon, Getting Started with SQL and Databases
https://doi.org/10.1007/978-1-4842-9493-2_1

1. Starting with SQL


Mark Simon1
(1) Ivanhoe VIC, VIC, Australia

If you’re new to database in general, and to SQL in particular, it can be a


little daunting at first. In this chapter, we’ll have a taste of SQL by looking
at how we fetch data from a simple table.
In principle, you can choose to manage your data any way you want,
and some people do just that in spreadsheets or even in word
processors. For serious data, that’s not organized enough, so we rely on
something more structured.
There is no one way to organize data, and not all data can be
organized in the same way. However, for much of the time, there is a
popular way of organizing the data for which the SQL language has been
developed. Software that manages a database is often referred to as
Database Management System that’s quite a lot to say every time, so
we’ll refer to it as DBMS.
An SQL database is a collection of one or more tables. Each table is a
collection of one type of data. Some of the tables in the sample database
are
Customers
Paintings
Artists
We will have a closer look at the structure of the database later, but
the important thing at this point is that the data is not mixed up. For
example, the customers table has all of the information about
customers, and nothing else.
Each table contains rows and columns. A row is one instance of the
data. For example, each row in the customers table represents one
customer. A column has a detail of the row. For example, the
customers table has separate columns for the customer’s email
address, phone number, and so on.
Of course, there’s more to a database than that, and Chapter 2 will
focus on these ideas more thoroughly.
In this chapter, we will explore the contents of one table, the
customers table, using the SELECT statement, which is the basic
command to fetch data. Along the way, you’ll see how the results can be
filtered, recalculated, and sorted.
Everything we cover here will be covered in more detail in later
chapters, so you can take a fairly relaxed approach to what we’re doing
in this chapter.

If you run the following sample code, your results may not be exactly
the same. This is because the sample data, which is randomized, may
not be the same as the data used in the book. You may also find
differences in the way DBMSs present unsorted data.

Basic SELECT Statement


To read data from a table, you use SELECT:

SELECT * FROM customers;

You’ll get a result similar to Table 1-1.

Table 1-1 Results

id familyname givenname email registered


474 Free Judy [email protected] … 2022-06-12
186 Gunn Ray [email protected] … 2021-11-15
144 King Ray [email protected] … 2021-10-18
179 Inkling Ivan [email protected] … 2021-11-08
475 Blood Drew [email protected] … 2022-06-13
id familyname givenname email registered
523 Sights Seymour [email protected] … 2022-07-11
~ 304 rows ~
This is called a SELECT statement and will fetch all the rows from
the customers table.
Statements usually comprise two or more clauses. In this case, they
are the SELECT clause and the FROM clause.

Note
SELECT doesn’t mean display, although the database client doesn’t
know what else to do with the results. Other software might simply
fetch the data to be further processed.
The * doesn’t mean all rows. It is a shorthand for all columns of the
table.
Most of what we’ll be doing will involve a SELECT statement.

Case Sensitivity
The SQL language is case insensitive, meaning that you can type the
statement in upper or lower case:

select * from customers;

It is traditional to use UPPER CASE for keywords (SELECT and FROM)


to highlight them, but it’s not so important when you have color
highlighting.
It is also traditional that table and column names be entered in lower
case, but most DBMSs don’t really care.
This book will use UPPER CASE for keywords, but you don’t have to.

Spacing
Although a simple statement might easily fit on one line, you can add as
many line breaks and extra spaces or tabs as you like:

SELECT
*
FROM customers;
The most important thing is to keep your code readable and to use
spacing to help in managing the statement.
As the book progresses, there will be more recommendations on
layout. However, these are recommendations only, as SQL will work just
as well with minimal spacing.

Clause Ordering
The original proposed name for SQL was SEQUEL, Structured English
Query Language. The idea was that the syntax would resemble the
English language.
This has led to a syntax quirk. For example, if you say

Get the Milk


From the Refrigerator

you first go to the refrigerator and then get the milk. That is, From is
processed before Get.
Similarly, in the SELECT statement, the FROM clause is processed
before the SELECT clause.
However, you cannot write the statement that way:
You must write SELECT … FROM … ;.
It means FROM … SELECT … ;.
Later, you will see additional clauses and where they fit in.
In this simple example, the fact of the clause order is not important.
However, later, the clause order will explain why some more complex
examples don’t work the way you would expect.

The Semicolon (;)


The SQL standard requires a semicolon ; at the end of each statement.
You can break up the statement over many lines, but the semicolon then
marks the eventual end of the statement.
Most DBMSs will allow you to ignore the semicolon if there is a single
statement. However, you will at least need a semicolon between
multiple statements.
Microsoft SQL will also allow you to omit semicolons for multiple
statements, unless you have them on one line, but even Microsoft
doesn’t think that’s a good idea (see
https://docs.microsoft.com/en-us/sql/t-
sql/language-elements/transact-sql-syntax-
conventions-transact-sql#transact-sql-syntax-
conventions-transact-sql).
We recommend that you always use semicolons, even for a single
statement or for Microsoft SQL. This way, you make sure that your code
is less prone to errors.

Selecting Specific Columns


The star character * is a shorthand for selecting all columns from the
table. You can specify one or more columns instead:

SELECT id, givenname, familyname


FROM customers;

This gives you Table 1-2.


Table 1-2 Results

id givenname familyname
474 Judy Free
186 Ray Gunn
144 Ray King
179 Ivan Inkling
475 Drew Blood
523 Seymour Sights
~ 304 rows ~

This selects three columns; it still selects all rows.


The column list is separated by commas:
The columns do not have to be in the original order.
You can skip any columns you like.
Note that in this case the givenname and familyname order is
reversed and that the email column is omitted.
The space after the comma is optional: include it if you think it makes
it more readable.
The comma is a separator: don’t put a column after the last column, as
SQL will expect another column.
This is a common mistake:

SELECT id, givenname, familyname, -- extra comma


FROM customers;

It’s a good idea to always specify the columns, even if it’s all of them.

Column Order
The default column order, which you see with SELECT *, is defined
when the table is created. You may not be able to change it, even if you
have permission.
In SQL, there is no correct column order, and there is no performance
difference if you select in a different order. That is, there is no preferred
column order, so you choose the order which best suits your needs,
either for presentation or to feed into another application.

Layout
With a growing column list, it makes sense to lay the columns out more
creatively:

SELECT
id,
givenname, familyname
FROM customers;

As mentioned before, the actual spacing is insignificant, so the


preceding example uses spacing to make the statement more readable.
The column list is vertical rather than inline.
The column list is indented from the SELECT command to show that
they are part of the same clause.
givenname and familyname are on the same line to show that
conceptually they are related to each other.
You will find layout easier to maintain if you remember to use the tab
key.
Also, as mentioned before, you can use any spacing you like; just
make sure that the statement is as readable as possible.

Using SELECT *
It is considered bad practice to use SELECT * in real life, even if you
really want all of the columns; always specify all of the columns. This is
because
You get no control over the column order of the results.
A change in the underlying table structure might lead to different
results next time.
However, in this book, you will see SELECT * used very often:
SELECT * is a good way of exploring a table.
Many examples will focus on new clauses, so the actual columns
selected are not relevant.
Just remember that when using SQL in earnest, you should always
list the actual column names.

Calculated Columns
The selected columns don’t have to be the original columns. They can be
derived from one or more columns. Among other things, this means that
the table never needs to keep variations on a value since it can always be
recalculated when the time comes.
For example:

SELECT
id, givenname, familyname,
height, -- height in centimetres
height/2.54 -- height in inches
FROM customers;
Table 1-3 shows the results.
Table 1-3 Results

474 Judy Free


186 Ray Gunn 163.8 64.488…
144 Ray King 176.8 69.606…
179 Ivan Inkling 170.3 67.047…
475 Drew Blood 171.0 67.323…
523 Seymour Sights 167.3 65.866…
~ 304 rows ~

In the customers table, height is measured in centimeters. For


those who prefer a legacy measurement, you can convert to inches by
dividing by 2.54.1
It would have been a mistake to design a table with both centimeters
and inches. Tables should never have a column which is basically the
same as another in disguise. As you see, you can always recalculate the
other value.

Aliases
When experimenting with a SELECT statement, you can leave
calculations as they are, but you will notice that the result will have a
missing or dummy name.
When taking your SELECT statement seriously, you will need to give
calculated columns a distinct name:

SELECT
id, givenname, familyname,
height as centimetres,
height/2.54 as inches
FROM customers;

Now you have the results in Table 1-4.

Table 1-4 Results


id givenname familyname centimetres inches
474 Judy Free [NULL] [NULL]
186 Ray Gunn 163.8 64.488…
144 Ray King 176.8 69.606…
179 Ivan Inkling 170.3 67.047…
475 Drew Blood 171.0 67.323…
523 Seymour Sights 167.3 65.866…
~ 304 rows ~
As you see, you can also alias uncalculated columns if you feel the
need to make the point clearer.
You will see more on calculated columns and aliases later.

Comments
In an elaborate script, it is useful to include comments about what is
going on. A comment is any text which will be ignored by SQL, but is
meant for humans to read.
You’ve already seen a few comments in the previous examples. The
standard comment is text following the -- characters, until the end of
the line:

SELECT
id, givenname, familyname,
height/2.54 as inches -- 1in = 2.54cm
FROM customers;

The preceding comment is to explain why we are dividing by 2.54.


Strictly speaking, the -- must be followed by a space. However,
most, but not all, DBMSs will allow a tab instead of a space, and some,
but not all, DBMSs don’t require spacing character:

-- This is a standard comment (space)


-- This uses a tab, and will probably work, but
not necessarily (tab)
--This may also work
You will find out soon enough which variations work for your DBMS.
Usually, comments are highlighted in a different color.

Block Comments
Most DBMSs also support an unofficial block comment:

/* block comment */

This style is also known as the C-style comment because of its use in
the C programming language.
The block comment begins with the /* combination and ends with
the reverse */ combination. It can span multiple lines or take up just
part of a line.

/* This is an introductory SELECT statement


The rest of the book will go into more detail
*/
SELECT
id,
/* name: */ givenname, familyname
FROM customers;

Normally, you should avoid non-standard SQL features, since you


never know what the future holds. However, this one is so widely
supported that you can regard it as simply a missing feature supplied
unofficially.

Uses of Comments
Since SQL completely ignores comment text, you can write anything you
like, even if it amounts to gibberish. However, the following are common
uses of comments:
Explain something which is not obvious in code
Act as section headers in complex scripts
Temporarily disable some code
Here is an example with different uses of comments:
/* SQL Sampler
================================================
This is an introductory SELECT statement
The rest of the book will go into more detail
================================================
*/
SELECT
id,
-- email,
givenname, familyname,
height/2.54 as inches -- 2.54 cm = 1 inch
FROM customers;
In the preceding example, the email column is disabled, the
inches column is explained, and the whole script is preceded by a
header comment block. The actual query is also indented for good
measure.
Normally, if you want to disable code, you simply delete it. Using a
comment instead is called commenting the code out. The reasons why
you would comment code out include
Testing or troubleshooting
Leaving it there as an option, subject to further consultation
Using it as an alternative to other code
As regards explanatory code, don’t overcomment. Only explain what
isn’t obvious. Saying too much is like the boy who cried wolf. As a rule,
others will simply tune out.

Filtering Rows
Often, you don’t want all rows of a table, but only some of them. The
WHERE clause is used to decide which rows to select:

SELECT
id,
givenname,familyname,
height/2.54 AS inches
FROM customers
WHERE state='NSW';
This time, you get what’s in Table 1-5.
Table 1-5 Results

id givenname familyname inches


474 Judy Free [NULL]
144 Ray King 69.606…
341 Val Idate 69.724…
351 Dick Tate 66.063…
429 Tom Morrow 61.772…
234 Nat Ering 67.638…
~ 67 rows ~

The expression state='NSW' is called an assertion and is either


true or false. The WHERE clause selects only those rows where the
assertion is true.
Note the single quotes ' … ' around the NSW. In SQL, text values
are called strings and are enclosed in single quotes. Don’t use double
quotes " … " because most DBMSs will interpret double quotes
differently. Also, note that the string is in UPPER CASE, which matches
the data in the customers table. In some DBMSs, you can also use lower
case, but not in others.
You will learn more about strings later in the book.

Clause Ordering
The WHERE clause is evaluated after FROM, but before SELECT:

SELECT …
FROM …
-- SELECT processed here!
WHERE … ;

In English, this reads as


1. Start with the table.
2. Filter some rows.

3. Select some columns.

Remember, however, that you must write the SQL in the preceding
order.

Placing the Semicolon


When developing your code, it is easy to make the following mistake:

SELECT *
FROM customers;
WHERE state='NSW' -- oops

This is because you have correctly ended the previous version with a
semicolon and simply added a new clause after it. While you are
developing your code, it may be helpful to put the semicolon on a
separate line:

SELECT *
FROM customers
WHERE state='NSW'
;

This makes it easier to add the additional clauses as you go. You can
always tidy up the semicolon when you have finished everything.

Ordering the Results


Mathematically speaking, a table is a set of rows. Among other things,
this means that row order is insignificant.
Some DBMSs will output the results in the same order they were
added. Some DBMSs will output them in a seemingly random order,
depending on how the data is managed internally.
The SQL standard makes a point of not telling a DBMS how to do its
job, and the only guarantee is that row order is not guaranteed, that is,
unless you force the issue.
The ORDER BY clause puts the results in a specified order:

SELECT
id,
givenname, familyname,
height/2.54 as inches
FROM customers
WHERE state='NSW'
ORDER BY familyname, givenname;

The results will appear in Table 1-6.

Table 1-6 Results

id givenname familyname inches


44 Helen Back 67.913…
162 Ginger Beer 70.039…
99 Minnie Bus 65.315…
270 Mary Christmas 65.118…
487 Horace Cope 68.622…
419 Barbie Cue 62.520…
~ 67 rows ~

In this example, you order the results by familyname and, in the


event of a tie, by the givenname.
You can order by one or more columns, in ascending or descending
order.
Strictly speaking, the result is no longer a set, as a set is unordered.
In some cases, you won’t be able to do any more processing once the
ORDER BY clause is used.
You will learn more about the ORDER BY clause later.

Clause Order
The ORDER BY is both written and evaluated last:

SELECT …
FROM …
WHERE …
-- SELECT processed here
ORDER BY … ;
In English, this reads as
1. Start with the table.

2. Filter some rows.

3. Select some columns.

4. Finally, sort the results.

Remember, however, that you must still write the SQL in the
preceding order.

Distinct Rows
Sometimes, you will need to interpret what somebody asks for. For
example, if you want a list of email addresses, the following would do
the job:

SELECT email FROM customers;

The results in Table 1-7 are reasonable enough.

Table 1-7 Results

email
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
email
~ 304 rows ~
On the other hand, if you want a list of states, the following is
probably not what you want:

SELECT state FROM customers;

The results in Table 1-8 are not so reasonable.


Table 1-8 Results

state
NSW
VIC
NSW
WA
QLD
VIC
NSW
NSW
QLD
TAS
~ 304 rows ~

You will, of course, get a list of all of the state values (as well as a few
NULLs which represent missing values). However, you probably don’t
want the duplicates. If you want one of each, you will need to use
DISTINCT:

SELECT DISTINCT state FROM customers; -- one of


each

The results in Table 1-9 are probably more reasonable.


Table 1-9 Results
state
WA
[NULL]
TAS
VIC
NSW
NT
QLD
SA
~ 8 rows ~
Using DISTINCT treats each value not as an individual value but as
a group. You can say that you now have the state groups.
Note that one of the groups is NULL, meaning that you also have
some missing states.
The DISTINCT operator acts only on what is in the SELECT clause.
If you add the town column as well:

SELECT DISTINCT state, town FROM customers; -- one


of each

You’ll get results like Table 1-10.


Table 1-10 Results

state town
SA Windsor
[NULL] [NULL]
VIC Belmont
SA Alberton
NSW Hamilton
WA Wattle Grove
VIC Stirling
VIC Gordon
state town
TAS Beaconsfield
SA Richmond
~ 79 rows ~
Here, you will get distinct combinations of state and town. In the
result set, it’s not the state which is distinct nor the town—it’s the
combination. We can say that we now have state/town groups.
Again, you will see the NULL as a separate group. In this set of data,
there is no state without a town and vice versa, which is why there’s
only one group with NULLs.

Summary
Here is a sample of the SQL we have been developing:

/* SQL Sampler
================================================
This is an introductory SELECT statement
The rest of the book will go into more detail
================================================
*/
SELECT
id,
-- email,
givenname, familyname,
height/2.54 as inches -- 2.54 cm = 1 inch
FROM customers
WHERE state='NSW'
ORDER BY familyname,givenname;

This illustrates the main parts of an SQL SELECT statement, as well


as the use of comments and layout.
The basic SELECT statement is

SELECT columns
FROM table;
Random documents with unrelated
content Scribd suggests to you:
modern days of exact sciences. Roger Bacon, the friar, was laughed
at as a quack, and is now generally numbered among “pretenders”
to magic art; but his discoveries were nevertheless accepted, and
are now used by those who ridicule him the most. Roger Bacon
belonged by right if not by fact to that Brotherhood which includes all
those who study the occult sciences. Living in the thirteenth century,
almost a contemporary, therefore, of Albertus Magnus and Thomas
Aquinas, his discoveries—such as gunpowder and optical glasses,
and his mechanical achievements—were considered by every one
as so many miracles. He was accused of having made a compact
with the Evil One.
In the legendary history of Friar Bacon, as “well as in an old play
written by Robert Green, a dramatist in the days of Queen Elizabeth,
it is recounted, that, having been summoned before the king, the friar
was induced to show” some of his skill before her majesty the queen.
So he waved his hand (his wand, says the text), and “presently was
heard such excellent music, that they all said they had never heard
the like.” Then there was heard a still louder music and four
apparitions suddenly presented themselves and danced until they
vanished and disappeared in the air. Then he waved his wand again,
and suddenly there was such a smell “as if all the rich perfumes in
the whole world had been there prepared in the best manner that art
could set them out.” Then Roger Bacon having promised a
gentleman to show him his sweetheart, he pulled a hanging in the
king’s apartment aside and every one in the room saw “a kitchen-
maid with a basting-ladle in her hand.” The proud gentleman,
although he recognized the maiden who disappeared as suddenly as
she had appeared, was enraged at the humiliating spectacle, and
threatened the friar with his revenge. What does the magician do?
He simply answers: “Threaten not, lest I do you more shame; and do
you take heed how you give scholars the lie again!”

As a commentary on this, the modern historian[141] remarks: “This


may be taken as a sort of exemplification of the class of exhibitions
which were probably the result of a superior knowledge of natural
sciences.” No one ever doubted that it was the result of precisely
such a knowledge, and the hermetists, magicians, astrologers and
alchemists never claimed anything else. It certainly was not their
fault that the ignorant masses, under the influence of an
unscrupulous and fanatical clergy, should have attributed all such
works to the agency of the devil. In view of the atrocious tortures
provided by the Inquisition for all suspected of either black or white
magic, it is not strange that these philosophers neither boasted nor
even acknowledged the fact of such an intercourse. On the contrary,
their own writings prove that they held that magic is “no more than
the application of natural active causes to passive things or subjects;
by means thereof, many tremendously surprising but yet natural
effects are produced.”
The phenomena of the mystic odors and music, exhibited by
Roger Bacon, have been often observed in our own time. To say
nothing of our personal experience, we are informed by English
correspondents of the Theosophical Society that they have heard
strains of the most ravishing music, coming from no visible
instrument, and inhaled a succession of delightful odors produced,
as they believed, by spirit-agency. One correspondent tells us that so
powerful was one of these familiar odors—that of sandal-wood—that
the house would be impregnated with it for weeks after the seance.
The medium in this case was a member of a private family, and the
experiments were all made within the domestic circle. Another
describes what he calls a “musical rap.” The potencies that are now
capable of producing these phenomena must have existed and been
equally efficacious in the days of Roger Bacon. As to the apparitions,
it suffices to say that they are evoked now in spiritualistic circles, and
guarantied by scientists, and their evocation by Roger Bacon is thus
made more probable than ever.
Baptista Porta, in his treatise on Natural Magic, enumerates a
whole catalogue of secret formulæ for producing extraordinary
effects by employing the occult powers of nature. Although the
“magicians” believed as firmly as our spiritualists in a world of
invisible spirits, none of them claimed to produce his effects under
their control or through their sole help. They knew too well how
difficult it is to keep away the elementary creatures when they have
once found the door wide open. Even the magic of the ancient
Chaldeans was but a profound knowledge of the powers of simples
and minerals. It was only when the theurgist desired divine help in
spiritual and earthly matters that he sought direct communication
through religious rites, with pure spiritual beings. With them, even,
those spirits who remain invisible and communicate with mortals
through their awakened inner senses, as in clairvoyance,
clairaudience and trance, could only be evoked subjectively and as a
result of purity of life and prayer. But all physical phenomena were
produced simply by applying a knowledge of natural forces, although
certainly not by the method of legerdemain, practiced in our days by
conjurers.
Men possessed of such knowledge and exercising such powers
patiently toiled for something better than the vain glory of a passing
fame. Seeking it not, they became immortal, as do all who labor for
the good of the race, forgetful of mean self. Illuminated with the light
of eternal truth, these rich-poor alchemists fixed their attention upon
the things that lie beyond the common ken, recognizing nothing
inscrutable but the First Cause, and finding no question unsolvable.
To dare, to know, to will, and remain silent, was their constant rule; to
be beneficent, unselfish, and unpretending, were, with them,
spontaneous impulses. Disdaining the rewards of petty traffic,
spurning wealth, luxury, pomp, and worldly power, they aspired to
knowledge as the most satisfying of all acquisitions. They esteemed
poverty, hunger, toil, and the evil report of men, as none too great a
price to pay for its achievement. They, who might have lain on
downy, velvet-covered beds, suffered themselves to die in hospitals
and by the wayside, rather than debase their souls and allow the
profane cupidity of those who tempted them to triumph over their
sacred vows. The lives of Paracelsus, Cornelius Agrippa, and
Philalethes are too well known to repeat the old, sad story.
If spiritualists are anxious to keep strictly dogmatic in their notions
of the “spirit-world,” they must not set scientists to investigate their
phenomena in the true experimental spirit. The attempt would most
surely result in a partial re-discovery of the magic of old—that of
Moses and Paracelsus. Under the deceptive beauty of some of their
apparitions, they might find some day the sylphs and fair Undines of
the Rosicrucians playing in the currents of psychic and odic force.
Already Mr. Crookes, who fully credits the being, feels that under
the fair skin of Katie, covering a simulacrum of heart borrowed
partially from the medium and the circle, there is no soul! And the
learned authors of The Unseen Universe, abandoning their “electro-
biological” theory, begin to perceive in the universal ether the
possibility that it is a photographic album of En-Soph—the
Boundless.
We are far from believing that all the spirits that communicate at
circles are of the classes called “Elemental,” and “Elementary.” Many
—especially among those who control the medium subjectively to
speak, write, and otherwise act in various ways—are human,
disembodied spirits. Whether the majority of such spirits are good or
bad, largely depends on the private morality of the medium, much on
the circle present, and a great deal on the intensity and object of
their purpose. If this object is merely to gratify curiosity and to pass
the time, it is useless to expect anything serious. But, in any case,
human spirits can never materialize themselves in propria personâ.
These can never appear to the investigator clothed with warm, solid
flesh, sweating hands and faces, and grossly-material bodies. The
most they can do is to project their æthereal reflection on the
atmospheric waves, and if the touch of their hands and clothing can
become upon rare occasions objective to the senses of a living
mortal, it will be felt as a passing breeze gently sweeping over the
touched spot, not as a human hand or material body. It is useless to
plead that the “materialized spirits” that have exhibited themselves
with beating hearts and loud voices (with or without a trumpet) are
human spirits. The voices—if such sound can be termed a voice at
all—of a spiritual apparition once heard can hardly be forgotten. That
of a pure spirit is like the tremulous murmur of an Æolian harp
echoed from a distance; the voice of a suffering, hence impure, if not
utterly bad spirit, may be assimilated to a human voice issuing from
an empty barrel.
This is not our philosophy, but that of the numberless generations
of theurgists and magicians, and based upon their practical
experience. The testimony of antiquity is positive on this subject:
“Δαιμονιῶν φωναὶ ἄναρθροι εἰσί....”[142] The voices of spirits are not
articulated. The spirit-voice consists of a series of sounds which
conveys the impression of a column of compressed air ascending
from beneath upward, and spreading around the living interlocutor.
The many eye-witnesses who testified in the case of Elizabeth
Eslinger, namely:[143] the deputy-governor of the prison of
Weinsberg, Mayer, Eckhart, Theurer, and Knorr (sworn evidence),
Düttenhöfer, and Kapff, the mathematician, testified that they saw
the apparition like a pillar of clouds. For the space of eleven weeks,
Doctor Kerner and his sons, several Lutheran ministers, the
advocate Fraas, the engraver Düttenhöfer, two physicians, Siefer
and Sicherer, the judge Heyd, and the Baron von Hugel, with many
others, followed this manifestation daily. During the time it lasted, the
prisoner Elizabeth prayed with a loud voice uninterruptedly;
therefore, as the “spirit” was talking at the same time, it could be no
ventriloquism; and that voice, they say,“had nothing human in it; no
one could imitate its sounds.”
Further on we will give abundant proofs from ancient authors
concerning this neglected truism. We will now only again assert that
no spirit claimed by the spiritualists to be human was ever proved to
be such on sufficient testimony. The influence of the disembodied
ones can be felt, and communicated subjectively by them to
sensitives. They can produce objective manifestations, but they
cannot produce themselves otherwise than as described above.
They can control the body of a medium, and express their desires
and ideas in various modes well known to spiritualists; but not
materialize what is matterless and purely spiritual—their divine
essence. Thus every so-called “materialization” when genuine—is
either produced (perhaps) by the will of that spirit whom the
“appearance” is claimed to be but can only personate at best, or by
the elementary goblins themselves, which are generally too stupid to
deserve the honor of being called devils. Upon rare occasions the
spirits are able to subdue and control these soulless beings, which
are ever ready to assume pompous names if left to themselves, in
such a way that the mischievous spirit “of the air,” shaped in the real
image of the human spirit, will be moved by the latter like a
marionette, and unable to either act or utter other words than those
imposed on him by the “immortal soul.” But this requires many
conditions generally unknown to the circles of even spiritualists most
in the habit of regularly attending seances. Not every one can attract
human spirits who likes. One of the most powerful attractions of our
departed ones is their strong affection for those whom they have left
on earth. It draws them irresistibly, by degrees, into the current of the
Astral Light vibrating between the person sympathetic to them and
the Universal Soul. Another very important condition is harmony, and
the magnetic purity of the persons present.
If this philosophy is wrong, if all the “materialized” forms emerging
in darkened rooms from still darker cabinets, are spirits of men who
once lived upon this earth, why such a difference between them and
the ghosts that appear unexpectedly—ex abrupto—without either
cabinet or medium? Who ever heard of the apparitions, unrestful
“souls,” hovering about the spots where they were murdered, or
coming back for some other mysterious reasons of their own, with
“warm hands” feeling like living flesh, and but that they are known to
be dead and buried, not distinguishable from living mortals? We
have well-attested facts of such apparitions making themselves
suddenly visible, but never, until the beginning of the era of the
“materializations,” did we see anything like them. In the Medium and
Day Break, of September 8, 1876, we read a letter from “a lady
travelling on the continent,” narrating a circumstance that happened
in a haunted house. She says: “ ... A strange sound proceeded from
a darkened corner of the library ... on looking up she perceived a
cloud or column of luminous vapor; ... the earth-bound spirit was
hovering about the spot rendered accursed by his evil deed....” As
this spirit was doubtless a genuine elementary apparition, which
made itself visible of its own free will—in short, an umbra—it was, as
every respectable shadow should be, visible but impalpable, or if
palpable at all, communicating to the feeling of touch the sensation
of a mass of water suddenly clasped in the hand, or of condensed
but cold steam. It was luminous and vapory; for aught we can tell it
might have been the real personal umbra of the “spirit,” persecuted,
and earth-bound, either by its own remorse and crimes or those of
another person or spirit. The mysteries of after-death are many, and
modern “materializations” only make them cheap and ridiculous in
the eyes of the indifferent.
To these assertions may be opposed a fact well known among
spiritualists: The writer has publicly certified to having seen such
materialized forms. We have most assuredly done so, and are ready
to repeat the testimony. We have recognized such figures as the
visible representations of acquaintances, friends, and even relatives.
We have, in company with many other spectators, heard them
pronounce words in languages unfamiliar not only to the medium
and to every one else in the room, except ourselves, but, in some
cases, to almost if not quite every medium in America and Europe,
for they were the tongues of Eastern tribes and peoples. At the time,
these instances were justly regarded as conclusive proofs of the
genuine mediumship of the uneducated Vermont farmer who sat in
the “cabinet.” But, nevertheless, these figures were not the forms of
the persons they appeared to be. They were simply their portrait
statues, constructed, animated and operated by the elementaries. If
we have not previously elucidated this point, it was because the
spiritualistic public was not then ready to even listen to the
fundamental proposition that there are elemental and elementary
spirits. Since that time this subject has been broached and more or
less widely discussed. There is less hazard now in attempting to
launch upon the restless sea of criticism the hoary philosophy of the
ancient sages, for there has been some preparation of the public
mind to consider it with impartiality and deliberation. Two years of
agitation have effected a marked change for the better.
Pausanias writes that four hundred years after the battle of
Marathon, there were still heard in the place where it was fought, the
neighing of horses and the shouts of shadowy soldiers. Supposing
that the spectres of the slaughtered soldiers were their genuine
spirits, they looked like “shadows,” not materialized men. Who, then,
or what, produced the neighing of horses? Equine “spirits?” And if it
be pronounced untrue that horses have spirits—which assuredly no
one among zoölogists, physiologists or psychologists, or even
spiritualists, can either prove or disprove—then must we take it for
granted that it was the “immortal souls” of men which produced the
neighing at Marathon to make the historical battle scene more vivid
and dramatic? The phantoms of dogs, cats, and various other
animals have been repeatedly seen, and the world-wide testimony is
as trustworthy upon this point as that with respect to human
apparitions. Who or what personates, if we are allowed such an
expression, the ghosts of departed animals? Is it, again, human
spirits? As the matter now stands, there is no side issue; we have
either to admit that animals have surviving spirits and souls as well
as ourselves, or hold with Porphyry that there are in the invisible
world a kind of tricky and malicious demons, intermediary beings
between living men and “gods,” spirits that delight in appearing
under every imaginable shape, beginning with the human form, and
ending with those of multifarious animals.[144]
Before venturing to decide the question whether the spectral
animal forms so frequently seen and attested are the returning spirits
of dead beasts, we must carefully consider their reported behavior.
Do these spectres act according to the habits and display the same
instincts, as the animals during life? Do the spectral beasts of prey
lie in wait for victims, and timid animals flee before the presence of
man; or do the latter show a malevolence and disposition to annoy,
quite foreign to their natures? Many victims of these obsessions—
notably, the afflicted persons of Salem and other historical
witchcrafts—testify to having seen dogs, cats, pigs, and other
animals, entering their rooms, biting them, trampling upon their
sleeping bodies, and talking to them; often inciting them to suicide
and other crimes. In the well-attested case of Elizabeth Eslinger,
mentioned by Dr. Kerner, the apparition of the ancient priest of
Wimmenthal[145] was accompanied by a large black dog, which he
called his father, and which dog in the presence of numerous
witnesses jumped on all the beds of the prisoners. At another time
the priest appeared with a lamb, and sometimes with two lambs.
Most of those accused at Salem were charged by the seeresses with
consulting and plotting mischief with yellow birds, which would sit on
their shoulder or on the beams overhead.[146] And unless we
discredit the testimony of thousands of witnesses, in all parts of the
world, and in all ages, and allow a monopoly of seership to modern
mediums, spectre-animals do appear and manifest all the worst traits
of depraved human nature, without themselves being human. What,
then, can they be but elementals?
Descartes was one of the few who believed and dared say that to
occult medicine we shall owe discoveries “destined to extend the
domain of philosophy;” and Brierre de Boismont not only shared in
these hopes but openly avowed his sympathy with
“supernaturalism,” which he considered the universal “grand creed” “
... We think with Guizot,” he says, “that the existence of society is
bound up in it. It is in vain that modern reason, which,
notwithstanding its positivism, cannot explain the intimate cause of
any phenomena, rejects the supernatural; it is universal, and at the
root of all hearts. The most elevated minds are frequently its most
ardent disciples.”[147]
Christopher Columbus discovered America, and Americus
Vespucius reaped the glory and usurped his dues. Theophrastus
Paracelsus rediscovered the occult properties of the magnet—“the
bone of Horus” which, twelve centuries before his time, had played
such an important part in the theurgic mysteries—and he very
naturally became the founder of the school of magnetism and of
mediæval magico-theurgy. But Mesmer, who lived nearly three
hundred years after him, and as a disciple of his school brought the
magnetic wonders before the public, reaped the glory that was due
to the fire-philosopher, while the great master died in a hospital!
So goes the world: new discoveries, evolving from old sciences;
new men—the same old nature!
CHAPTER III.
“The mirror of the soul cannot reflect both earth and heaven; and the one
vanishes from its surface, as the other is glassed upon its deep.”
Zanoni.
“Qui, donc, t’a donné la mission d’annoncer au peuple que la Divinité n’existe
pas—quel avantage trouves tu à persuader à l’homme qu’une force aveugle
préside à ses destinées et frappe au hazard le crime et la vertu?”
Robespierre (Discours), May 7, 1794.

W e believe that few of those physical phenomena which are


genuine are caused by disembodied human spirits. Still, even
those that are produced by occult forces of nature, such as happen
through a few genuine mediums, and are consciously employed by
the so-called “jugglers” of India and Egypt, deserve a careful and
serious investigation by science; especially now that a number of
respected authorities have testified that in many cases the
hypothesis of fraud does not hold. No doubt, there are professed
“conjurors” who can perform cleverer tricks than all the American
and English “John Kings” together. Robert Houdin unquestionably
could, but this did not prevent his laughing outright in the face of the
academicians, when they desired him to assert in the newspapers,
that he could make a table move, or rap answers to questions,
without contact of hands, unless the table was a prepared one.[148]
The fact alone, that a now notorious London juggler refused to
accept a challenge for £1,000 offered him by Mr. Algernon Joy,[149]
to produce such manifestations as are usually obtained through
mediums, unless he was left unbound and free from the hands of a
committee, negatives his exposé of the occult phenomena. Clever as
he may be, we defy and challenge him to reproduce, under the same
conditions, the “tricks” exhibited even by a common Indian juggler.
For instance, the spot to be chosen by the investigators at the
moment of the performance, and the juggler to know nothing of the
choice; the experiment to be made in broad daylight, without the
least preparations for it; without any confederate but a boy absolutely
naked, and the juggler to be in a condition of semi-nudity. After that,
we should select out of a variety three tricks, the most common
among such public jugglers, and that were recently exhibited to
some gentlemen belonging to the suite of the Prince of Wales: I. To
transform a rupee—firmly clasped in the hand of a skeptic—into a
living cobra, the bite of which would prove fatal, as an examination of
its fangs would show. 2. To cause a seed chosen at random by the
spectators, and planted in the first semblance of a flower-pot,
furnished by the same skeptics, to grow, mature, and bear fruit in
less than a quarter of an hour. 3. To stretch himself on three swords,
stuck perpendicularly in the ground at their hilts, the sharp points
upward; after that, to have removed first one of the swords, then the
other, and, after an interval of a few seconds, the last one, the
juggler remaining, finally, lying on nothing—on the air, miraculously
suspended at about one yard from the ground. When any
prestidigitateur, to begin with Houdin and end with the last trickster
who has secured gratuitous advertisement by attacking spiritualism,
does the same, then—but only then—we will train ourselves to
believe that mankind has been evolved out of the hind-toe of Mr.
Huxley’s Eocene Orohippus.
We assert again, in full confidence, that there does not exist a
professional wizard, either of the North, South or West, who can
compete with anything approaching success, with these untutored,
naked sons of the East. These require no Egyptian Hall for their
performances, nor any preparations or rehearsals; but are ever
ready, at a moment’s notice, to evoke to their help the hidden powers
of nature, which, for European prestidigitateurs as well as for
scientists, are a closed book. Verily, as Elihu puts it, “great men are
not always wise; neither do the aged understand judgment.”[150] To
repeat the remark of the English divine, Dr. Henry More, we may well
say: “ ... indeed, if there were any modesty left in mankind, the
histories of the Bible might abundantly assure men of the existence
of angels and spirits.” The same eminent man adds, “I look upon it
as a special piece of Providence that ... fresh examples of
apparitions may awaken our benumbed and lethargic minds into an
assurance that there are other intelligent beings besides those that
are clothed in heavy earth or clay ... for this evidence, showing that
there are bad spirits, will necessarily open a door to the belief that
there are good ones, and lastly, that there is a God.” The instance
above given carries a moral with it, not only to scientists, but
theologians. Men who have made their mark in the pulpit and in
professors’ chairs, are continually showing the lay public that they
really know so little of psychology, as to take up with any plausible
schemer who comes their way, and so make themselves ridiculous
in the eyes of the thoughtful student. Public opinion upon this subject
has been manufactured by jugglers and self-styled savants,
unworthy of respectful consideration.
The development of psychological science has been retarded far
more by the ridicule of this class of pretenders, than by the inherent
difficulties of its study. The empty laugh of the scientific nursling or of
the fools of fashion, has done more to keep man ignorant of his
imperial psychical powers, than the obscurities, the obstacles and
the dangers that cluster about the subject. This is especially the case
with spiritualistic phenomena. That their investigation has been so
largely confined to incapables, is due to the fact that men of science,
who might and would have studied them, have been frightened off by
the boasted exposures, the paltry jokes, and the impertinent clamor
of those who are not worthy to tie their shoes. There are moral
cowards even in university chairs. The inherent vitality of modern
spiritualism is proven in its survival of the neglect of the scientific
body, and of the obstreperous boasting of its pretended exposers. If
we begin with the contemptuous sneers of the patriarchs of science,
such as Faraday and Brewster, and end with the professional (?)
exposés of the successful mimicker of the phenomena,——, of
London, we will not find them furnishing one single, well-established
argument against the occurrence of spiritual manifestations. “My
theory is,” says this individual, in his recent soi-disant “exposé,” “that
Mr. Williams dressed up and personified John King and Peter.
Nobody can prove that it wasn’t so.” Thus it appears that,
notwithstanding the bold tone of assertion, it is but a theory after all,
and spiritualists might well retort upon the exposer, and demand that
he should prove that it is so.
But the most inveterate, uncompromising enemies of Spiritualism
are a class very fortunately composed of but few members, who,
nevertheless, declaim the louder and assert their views with a
clamorousness worthy of a better cause. These are the pretenders
to science of young America—a mongrel class of pseudo-
philosophers, mentioned at the opening of this chapter, with
sometimes no better right to be regarded as scholars than the
possession of an electrical machine, or the delivery of a puerile
lecture on insanity and mediomania. Such men are—if you believe
them—profound thinkers and physiologists; there is none of your
metaphysical nonsense about them; they are Positivists—the mental
sucklings of Auguste Comte, whose bosoms swell at the thought of
plucking deluded humanity from the dark abyss of superstition, and
rebuilding the cosmos on improved principles. Irascible
psychophobists, no more cutting insult can be offered them than to
suggest that they may be endowed with immortal spirits. To hear
them, one would fancy that there can be no other souls in men and
women than “scientific” or “unscientific souls;” whatever that kind of
soul may be.[151]
Some thirty or forty years ago, in France, Auguste Comte—a pupil
of the Ecole Polytechnique, who had remained for years at that
establishment as a repetiteur of Transcendant Analysis and
Rationalistic Mechanics—awoke one fine morning with the very
irrational idea of becoming a prophet. In America, prophets can be
met with at every street-corner; in Europe, they are as rare as black
swans. But France is the land of novelties. Auguste Comte became
a prophet; and so infectious is fashion, sometimes, that even in
sober England he was considered, for a certain time, the Newton of
the nineteenth century.
The epidemic extended, and for the time being, it spread like
wildfire over Germany, England, and America. It found adepts in
France, but the excitement did not last long with these. The prophet
needed money: the disciples were unwilling to furnish it. The fever of
admiration for a religion without a God cooled off as quickly as it had
come on; of all the enthusiastic apostles of the prophet, there
remained but one worthy any attention. It was the famous philologist
Littré, a member of the French Institute, and a would-be member of
the Imperial Academy of Sciences, but whom the archbishop of
Orleans maliciously prevented from becoming one of the
“Immortals.”[152]
The philosopher-mathematician—the high-priest of the “religion of
the future” taught his doctrine as do all his brother-prophets of our
modern days. He deified “woman,” and furnished her with an altar;
but the goddess had to pay for its use. The rationalists had laughed
at the mental aberration of Fourier; they had laughed at the St.
Simonists; and their scorn for Spiritualism knew no bounds. The
same rationalists and materialists were caught, like so many empty-
headed sparrows, by the bird-lime of the new prophet’s rhetoric. A
longing for some kind of divinity, a craving for the “unknown,” is a
feeling congenital in man; hence the worst atheists seem not to be
exempt from it. Deceived by the outward brilliancy of this ignus
fatuus, the disciples followed it until they found themselves
floundering in a bottomless morass.
Covering themselves with the mask of a pretended erudition, the
Positivists of this country have organized themselves into clubs and
committees with the design of uprooting Spiritualism, while
pretending to impartially investigate it.
Too timid to openly challenge the churches and the Christian
doctrine, they endeavor to sap that upon which all religion is based—
man’s faith in God and his own immortality. Their policy is to ridicule
that which affords an unusual basis for such a faith—phenomenal
Spiritualism. Attacking it at its weakest side, they make the most of
its lack of an inductive method, and of the exaggerations that are to
be found in the transcendental doctrines of its propagandists. Taking
advantage of its unpopularity, and displaying a courage as furious
and out of place as that of the errant knight of La Mancha, they claim
recognition as philanthropists and benefactors who would crush out
a monstrous superstition.
Let us see in what degree Comte’s boasted religion of the future is
superior to Spiritualism, and how much less likely its advocates are
to need the refuge of those lunatic asylums which they officiously
recommend for the mediums whom they have been so solicitous
about. Before beginning, let us call attention to the fact that three-
fourths of the disgraceful features exhibited in modern Spiritualism
are directly traceable to the materialistic adventurers pretending to
be spiritualists. Comte has fulsomely depicted the “artificially-
fecundated” woman of the future. She is but elder sister to the
Cyprian ideal of the free-lovers. The immunity against the future
offered by the teachings of his moon-struck disciples, has inoculated
some pseudo-spiritualists to such an extent as to lead them to form
communistic associations. None, however, have proved long-lived.
Their leading feature being generally a materialistic animalism,
gilded over with a thin leaf of Dutch-metal philosophy and tricked out
with a combination of hard Greek names, the community could not
prove anything else than a failure.
Plato, in the fifth book of the Republic, suggests a method for
improving the human race by the elimination of the unhealthy or
deformed individuals, and by coupling the better specimens of both
sexes. It was not to be expected that the “genius of our century,”
even were he a prophet, would squeeze out of his brain anything
entirely new.
Comte was a mathematician. Cleverly combining several old
utopias, he colored the whole, and, improving on Plato’s idea,
materialized it, and presented the world with the greatest monstrosity
that ever emanated from a human mind!
We beg the reader to keep in view, that we do not attack Comte as
a philosopher, but as a professed reformer. In the irremediable
darkness of his political, philosophical and religious views, we often
meet with isolated observations and remarks in which profound logic
and judiciousness of thought rival the brilliancy of their interpretation.
But then, these dazzle you like flashes of lightning on a gloomy
night, to leave you, the next moment, more in the dark than ever. If
condensed and repunctuated, his several works might produce, on
the whole, a volume of very original aphorisms, giving a very clear
and really clever definition of most of our social evils; but it would be
vain to seek, either through the tedious circumlocution of the six
volumes of his Cours de Philosophie Positive, or in that parody on
priesthood, in the form of a dialogue—The Catechism of the Religion
of Positivism—any idea suggestive of even provisional remedies for
such evils. His disciples suggest that the sublime doctrines of their
prophet were not intended for the vulgar. Comparing the dogmas
preached by Positivism with their practical exemplifications by its
apostles, we must confess the possibility of some very achromatic
doctrine being at the bottom of it. While the “high-priest” preaches
that “woman must cease to be the female of the man;”[153] while the
theory of the positivist legislators on marriage and the family, chiefly
consists in making the woman the “mere companion of man by
ridding her of every maternal function;”[154] and while they are
preparing against the future a substitute for that function by applying
“to the chaste woman” “a latent force,”[155] some of its lay priests
openly preach polygamy, and others affirm that their doctrines are
the quintessence of spiritual philosophy.
In the opinion of the Romish clergy, who labor under a chronic
nightmare of the devil, Comte offers his “woman of the future” to the
possession of the “incubi.”[156] In the opinion of more prosaic
persons, the Divinity of Positivism, must henceforth be regarded as a
biped broodmare. Even Littré made prudent restrictions while
accepting the apostleship of this marvellous religion. This is what he
wrote in 1859:
“M. Comte not only thought that he found the principles, traced the
outlines, and furnished the method, but that he had deduced the
consequences and constructed the social and religious edifice of the
future. It is in this second division that we make our reservations,
declaring, at the same time, that we accept as an inheritance, the
whole of the first.”[157]
Further, he says: “M. Comte, in a grand work entitled the System
of the Positive Philosophy, established the basis of a philosophy [?]
which must finally supplant every theology and the whole of
metaphysics. Such a work necessarily contains a direct application
to the government of societies; as it has nothing arbitrary in it [?] and
as we find therein a real science [?], my adhesion to the principles
involves my adhesion to the essential consequences.”
M. Littré has shown himself in the light of a true son of his prophet.
Indeed the whole system of Comte appears to us to have been built
on a play of words. When they say “Positivism” read Nihilism; when
you hear the word chastity, know that it means impudicity; and so on.
Being a religion based on a theory of negation, its adherents can
hardly carry it out practically without saying white when meaning
black!
“Positive Philosophy,” continues Littré, “does not accept atheism,
for the atheist is not a really-emancipated mind, but is, in his own
way, a theologian still; he gives his explanation about the essence of
things; he knows how they begun!... Atheism is Pantheism; this
system is quite theological yet, and thus belongs to the ancient
party.”[158]
It really would be losing time to quote any more of these
paradoxical dissertations. Comte attained to the apotheosis of
absurdity and inconsistency when, after inventing his philosophy, he
named it a “Religion.” And, as is usually the case, the disciples have
surpassed the reformer—in absurdity. Supposititious philosophers,
who shine in the American academies of Comte, like a lampyris
noctiluca beside a planet, leave us in no doubt as to their belief, and
contrast “that system of thought and life” elaborated by the French
apostle with the “idiocy” of Spiritualism; of course to the advantage of
the former. “To destroy, you must replace;” exclaims the author of the
Cathechism of the Religion of Positivism, quoting Cassaudiere, by
the way, without crediting him with the thought; and his disciples
proceed to show by what sort of a loathsome system they are
anxious to replace Christianity, Spiritualism, and even Science.
“Positivism,” perorates one of them, “is an integral doctrine. It
rejects completely all forms of theological and metaphysical belief; all
forms of supernaturalism, and thus—Spiritualism. The true positive
spirit consists in substituting the study of the invariable laws of
phenomena for that of their so-called causes, whether proximate or
primary. On this ground it equally rejects atheism; for the atheist is at
bottom a theologian,” he adds, plagiarizing sentences from Littré’s
works: “the atheist does not reject the problems of theology, only the
solution of these, and so he is illogical. We Positivists reject the
problem in our turn on the ground that it is utterly inaccessible to the
intellect, and we would only waste our strength in a vain search for
first and final causes. As you see, Positivism gives a complete
explanation [?] of the world, of man, his duty and destiny....”![159]
Very brilliant this; and now, by way of contrast, we will quote what
a really great scientist, Professor Hare, thinks of this system.
“Comte’s positive philosophy,” he says, “after all, is merely negative.
It is admitted by Comte, that he knows nothing of the sources and
causes of nature’s laws; that their origination is so perfectly
inscrutable as to make it idle to take up time in any scrutiny for that
purpose.... Of course his doctrine makes him avowedly a thorough
ignoramus, as to the causes of laws, or the means by which they are
established, and can have no basis but the negative argument above
stated, in objecting to the facts ascertained in relation to the spiritual
creation. Thus, while allowing the atheist his material dominion,
Spiritualism will erect within and above the same space a dominion
of an importance as much greater as eternity is to the average
duration of human life, and as the boundless regions of the fixed
stars are to the habitable area of this globe.”[160]
In short, Positivism proposes to itself to destroy Theology,
Metaphysics, Spiritualism, Atheism, Materialism, Pantheism, and
Science, and it must finally end in destroying itself. De Mirville thinks
that according to Positivism, “order will begin to reign in the human
mind only on the day when psychology will become a sort of cerebral
physics, and history a kind of social physics.” The modern
Mohammed first disburdens man and woman of God and their own
soul, and then unwittingly disembowels his own doctrine with the too
sharp sword of metaphysics, which all the time he thought he was
avoiding, thus letting out every vestige of philosophy.
In 1864, M. Paul Janet, a member of the Institute, pronounced a
discourse upon Positivism, in which occur the following remarkable
words:
“There are some minds which were brought up and fed on exact
and positive sciences, but which feel nevertheless, a sort of
instinctive impulse for philosophy. They can satisfy this instinct but
with elements that they have already on hand. Ignorant in
psychological sciences, having studied only the rudiments of
metaphysics, they nevertheless are determined to fight these same
metaphysics as well as psychology, of which they know as little as of
the other. After this is done, they will imagine themselves to have
founded a Positive Science, while the truth is that they have only
built up a new mutilated and incomplete metaphysical theory. They
arrogate to themselves the authority and infallibility properly
belonging alone to the true sciences, those which are based on
experience and calculations; but they lack such an authority, for their
ideas, defective as they may be, nevertheless belong to the same
class as those which they attack. Hence the weakness of their
situation, the final ruin of their ideas, which are soon scattered to the
four winds.”[161]
The Positivists of America have joined hands in their untiring
efforts to overthrow Spiritualism. To show their impartiality, though,
they propound such novel queries as follows: “ ... how much
rationality is there in the dogmas of the Immaculate Conception, the
Trinity and Transubstantiation, if submitted to the tests of physiology,
mathematics, and chemistry?” and they “undertake to say, that the
vagaries of Spiritualism do not surpass in absurdity these eminently
respectable beliefs.” Very well. But there is neither theological
absurdity nor spiritualistic delusion that can match in depravity and
imbecility that positivist notion of “artificial fecundation.” Denying to
themselves all thought on primal and final causes, they apply their
insane theories to the construction of an impossible woman for the
worship of future generations; the living, immortal companion of man
they would replace with the Indian female fetich of the Obeah, the
wooden idol that is stuffed every day with serpents’ eggs, to be
hatched by the heat of the sun!
And now, if we are permitted to ask in the name of common-
sense, why should Christian mystics be taxed with credulity or the
spiritualists be consigned to Bedlam, when a religion embodying
such revolting absurdity finds disciples even among Academicians?
—when such insane rhapsodies as the following can be uttered by
the mouth of Comte and admired by his followers: “My eyes are
dazzled;—they open each day more and more to the increasing
coincidence between the social advent of the feminine mystery, and
the mental decadence of the eucharistical sacrament. Already the
Virgin has dethroned God in the minds of Southern Catholics!
Positivism realizes the Utopia of the mediæval ages, by representing
all the members of the great family as the issue of a virgin mother
without a husband....” And again, after giving the modus operandi:
“The development of the new process would soon cause to spring up
a caste without heredity, better adapted than vulgar procreation to
the recruitment of spiritual chiefs, or even temporal ones, whose
authority would then rest upon an origin truly superior, which would
not shrink from an investigation.”[162]
To this we might inquire with propriety, whether there has ever
been found in the “vagaries of Spiritualism,” or the mysteries of
Christianity, anything more preposterous than this ideal “coming
race.” If the tendency of materialism is not grossly belied by the
behavior of some of its advocates, those who publicly preach
polygamy, we fancy that whether or not there will ever be a
sacerdotal stirp so begotten, we shall see no end of progeny,—the
offspring of “mothers without husbands.”
How natural that a philosophy which could engender such a caste
of didactic incubi, should express through the pen of one of its most
garrulous essayists, the following sentiments: “This is a sad, a very
sad age,[163] full of dead and dying faiths; full of idle prayers sent out
in vain search for the departing gods. But oh! it is a glorious age, full
of the golden light which streams from the ascending sun of science!
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!

ebookmass.com

You might also like