Article:
 |
|
What I Hate About Your Programming Language
|
| Subject: |
|
Re: What I Hate About SQL |
| Date: |
|
2005-12-29 04:29:23 |
| From: |
|
Scott_Kirkwood
|
Response to: Re: What I Hate About SQL
|
What I hate about SQL is that it's so inconsistent:
SELECT <columns> FROM <tables> WHERE <conditionals>
UPDATE <table> SET <column>=<value> WHERE <conditionals>
INSERT INTO <table> (<columns>) VALUES (<values)
Converting an insert into an update or select is more painful than it needs to be. I'd prefer:
UPDATE <columns>=<value> FROM <tables> WHERE <conditional>
and
INSERT <columns>=<values> INTO <tables> WHERE <conditionals>
I'd also make AND interchangeable with WHERE and trailing commas would be acceptable (like in Python), for example:
SELECT
A,
B,
C,
FROM myTable
AND a > 1
AND b < 1
|
Showing messages 1 through 1 of 1.
-
Re: What I Hate About SQL
2005-12-29 09:53:44
ababiec
[Reply | View]
INSERT INTO <table> (<columns>) SELECT <columns> FROM <tables> WHERE <conditionals>
And INSERTs don't require a columns list if the values match the column order of the table.
Never mind examples such as...
INSERT ALL
WHEN order_total < 1000000 THEN
INTO small_orders
WHEN order_total > 1000000 AND order_total < 2000000 THEN
INTO medium_orders
WHEN order_total > 2000000 THEN
INTO large_orders
SELECT order_id, order_total, sales_rep_id, customer_id
FROM orders;