SQL's posterous http://sqlstudies.posterous.com Most recent posts at SQL's posterous posterous.com Tue, 23 Feb 2010 17:16:32 -0800 Inline queries - do more with the FROM clause http://sqlstudies.posterous.com/inline-queries-do-more-with-the-from-clause http://sqlstudies.posterous.com/inline-queries-do-more-with-the-from-clause Table names aren't the only thing that can come after FROM. You can use entire queries, as described on JustinSomnia.org's great SQL tips and tricks page.

His example: "

select *from (select sal as salary, comm as commission from emp) xwhere salary < 5000;
"

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Mon, 22 Feb 2010 13:18:29 -0800 "Swearing in sign language" (in SQL) http://sqlstudies.posterous.com/swearing-in-sign-language-in-sql http://sqlstudies.posterous.com/swearing-in-sign-language-in-sql
 

"There's a Finger For That"


Only at Thinkgeek.com

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Wed, 17 Feb 2010 17:07:29 -0800 SQL on Urban Dictionary http://sqlstudies.posterous.com/sql-on-urban-dictionary http://sqlstudies.posterous.com/sql-on-urban-dictionary

SQL

Structured Query Language. The most common language used for accessing relational databases.


Custom Urban Dictionary Magnet magnet
Custom Urban Dictionary Magnet by UrbanDictionary
Get magnets at zazzle


Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Sun, 14 Feb 2010 22:38:27 -0800 SQL humor - "0 rows returned" http://sqlstudies.posterous.com/sql-humor-0-rows-returned http://sqlstudies.posterous.com/sql-humor-0-rows-returned
Sql_clue

There is a plethora of SQL humor out there that center on the "0 rows returned" (i.e. "nothing found").

Here's a good example ... "clueless management".

http://blog.drscottfranklin.net/2008/01/15/a-little-sql-humor/

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Sat, 13 Feb 2010 12:01:45 -0800 Safe SQL: always be on TOP. http://sqlstudies.posterous.com/safe-sql-always-be-on-top http://sqlstudies.posterous.com/safe-sql-always-be-on-top SQL likes being on TOP.

It's really an issue of peace-of-mind when query building.

Knowing your test query will never spin out of control.

Safe SQL always uses TOP until the last moment. When crafting a compex query one baby step at a time, TOP keeps the intermediate results short, snappy, and safe.

SELECT top 10 *... should be habitual.

Make sure you know how to use TOP in all kinds of situations.
W3C TOP

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Thu, 28 Jan 2010 10:36:26 -0800 MySQL site - great resource for syntax, code examples http://sqlstudies.posterous.com/mysql-site-great-resource-for-syntax-code-exa http://sqlstudies.posterous.com/mysql-site-great-resource-for-syntax-code-exa
Mysql_logo

My preferred flavor of SQL is MySQL. Why? It comes with the web host I use most frequently. I'm not a SQL whiz. I know just enough to get by. Industrial SQL gurus - you probably have a million reasons why MySQL isn't that great, but for modest applications and on-the-side-hobby needs, MySQL is just right. It's easy to use with PHP and is ... well, priced "just right".

Also their site is a great resource of syntax and examples. For example, if you wanted to know everything you could ever do with the SELECT statement, you'll be blown away by this page.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Thu, 21 Jan 2010 09:07:07 -0800 Inner joins - relating data between tables http://sqlstudies.posterous.com/inner-joins-relating-data-between-tables http://sqlstudies.posterous.com/inner-joins-relating-data-between-tables The SQL join is what relational DB' are all about. The syntax can either be explicit or implicit. I find the explicit notation is safer because the ON clause is a constant reminder of the join. The implicit notation uses the WHERE clause and you can more easily lose track of important relationships in complex queries. Also it's easier for others to follow explicit joins.

Sample syntax below is from wikipedia.

"SQL specifies two different syntactical ways to express joins: "explicit join notation" and "implicit join notation".

The "explicit join notation" uses the JOIN keyword to specify the table to join, and the ON keyword to specify the predicates for the join, as in the following example:

SELECT * FROM employee INNER JOIN department ON employee.DepartmentID = department.DepartmentID

The "implicit join notation" simply lists the tables for joining (in the FROM clause of the SELECT statement), using commas to separate them. Thus, it specifies a cross-join, and the WHERE clause may apply additional filter-predicates (which function comparably to the join-predicates in the explicit notation).

The following example shows a query which is equivalent to the one from the previous example, but this time written using the implicit join notation:

SELECT * FROM employee, department  
WHERE employee.DepartmentID = department.DepartmentID"

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Wed, 20 Jan 2010 15:42:50 -0800 GROUP BY - little gem for aggregating data http://sqlstudies.posterous.com/group-by-little-gem-for-aggregating-data http://sqlstudies.posterous.com/group-by-little-gem-for-aggregating-data
When you need to count (or sum, or aggregate) data and see the results "for each of something", then GROUP BY is probably what you want.

Note: you have to make sure that the SELECT columns appear in the GROUP BY clause - up to the last aggregator.

From W3Schools.com:

The GROUP BY statement is used in conjunction with the aggregate functions to group the result-set by one or more columns.

SQL GROUP BY Syntax

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
"

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Mon, 18 Jan 2010 22:26:12 -0800 SQL Case statement: condition http://sqlstudies.posterous.com/sql-case-statement-condition http://sqlstudies.posterous.com/sql-case-statement-condition This is a good tool to have in your SQL query toolbox: Sql CASE

From http://www.tizag.com/sqlTutorial/sqlcase.php

"SQL CASE is a very unique conditional statement providing if/then/else logic for any ordinary SQL command, such as SELECT or UPDATE. It then provides when-then-else functionality (WHEN this condition is met THEN do_this)."

Sample:

"USE mydatabase;

SELECT product,
      'Status' = CASE
        WHEN quantity > 0 THEN 'in stock'
        ELSE 'out of stock'
        END
FROM dbo.inventory;"

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Sat, 16 Jan 2010 11:11:07 -0800 SQL mug: clueless query http://sqlstudies.posterous.com/sql-mug-clueless-query http://sqlstudies.posterous.com/sql-mug-clueless-query An oldie but a goodie...

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Tue, 12 Jan 2010 23:59:40 -0800 Another SQL tutorial webiste http://sqlstudies.posterous.com/another-sql-tutorial-webiste http://sqlstudies.posterous.com/another-sql-tutorial-webiste Once you are done with W3Schools, you can move on to a site liket http://www.sql-tutorial.net/.

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Sun, 10 Jan 2010 15:34:38 -0800 Twitter thinks I'm Spanish. http://sqlstudies.posterous.com/twitter-thinks-im-spanish http://sqlstudies.posterous.com/twitter-thinks-im-spanish My "welcome to Twitter" email was completely in Spanish. I wonder what gave them that idea?

¡Hola, nuevo Twittero!

Aquí está la información de tu cuenta.

  • Tu nombre de usuario: ....

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Sun, 10 Jan 2010 15:33:09 -0800 Learning SQL - gotta start somewhere! W3Schools has a great basic tutorial. http://sqlstudies.posterous.com/learning-sql-gotta-start-somewhere-w3schools http://sqlstudies.posterous.com/learning-sql-gotta-start-somewhere-w3schools
W3sql

W3Schools.com has taught me the rudimentaries of many different languages and technologies. Here's how they describe their "up and running" online tutorial for SQL:

"SQL is a standard language for accessing databases.

Our SQL tutorial will teach you how to use SQL to access and manipulate data in:

MySQL, SQL Server, Access, Oracle, Sybase, DB2, and other database systems."

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies
Sun, 10 Jan 2010 15:22:09 -0800 Setting up Posterous Acccount http://sqlstudies.posterous.com/setting-up-posterous-acccount http://sqlstudies.posterous.com/setting-up-posterous-acccount First post

Permalink | Leave a comment  »

]]>
http://posterous.com/images/profile/missing-user-75.png http://posterous.com/users/3sObC644Gccp SQL Studies SQL SQL Studies