Standard Query Language
From Docunext Technology Wiki
Contents |
What is SQL?
Most people view SQL as a simple way to get information in and out of a database, but it can actually do quite a lot besides that.
As far as I know, SQL is a standard language, meaning that the logic behind how it works is an open publication by ANSI and can be used by anyone royalty free.
Example
SELECT * FROM tablename;
LEFT JOIN Example
SELECT DISTINCT pb_entry_amounts.entry_id,
pb_entry_amounts.account_id,
pb_entry_amounts.entry_amount_id,
pb_entry_amounts.entry_amount,
pb_entry_amounts.entry_type_id,
pb_accounts.name,
pb_accounts.account_type_id,
pb_general_ledger.account_id as posted_account_id
FROM (pb_accounts, pb_entry_amounts)
LEFT JOIN pb_general_ledger
ON pb_general_ledger.entry_amount_id=pb_entry_amounts.entry_amount_id
WHERE pb_entry_amounts.entry_id LIKE ?
AND pb_accounts.id = pb_entry_amounts.account_id
AND
(
pb_general_ledger.account_id IS NULL
OR
pb_general_ledger.account_id = 0
)
ORDER BY
pb_entry_amounts.entry_type_id DESC
( Taken from PBooks)
Best Practices use SQL
One of the first mistakes I made in developing web applications was not appreciating SQL as a method of manipulating and handling data. I only used it for I/O.
Nowadays when I develop web applications, I try to put a bunch of logic in my queries, rather than my application. I do so because SQL is quite mature, simple, and can be optimized in many ways.
I have learned a lot by using phpMyAdmin, such as adding "LIMIT 1" at the end of delete queries... just in case! Unfortunately, I don't think that it is standard SQL.