| Article: |
What I Hate About Your Programming Language | |
| Subject: | Re: What I Hate About SQL | |
| Date: | 2003-05-14 19:25:41 | |
| From: | anonymous2 | |
|
Yes, SQL is often thought of as Not A Real Programming Language. I think there are two types of developers: those who think naturally in sets, and those who don't. Not that one is better than the other, but I think naturally in sets, and love the logic behind that approach. I tend to solve most of my biggest problems that way.
|
||
Showing messages 1 through 2 of 2.
-
Re: What I Hate About SQL
2005-12-29 04:29:23 Scott_Kirkwood [Reply | View]
-
Re: What I Hate About SQL
2005-12-29 09:53:44 ababiec [Reply | View]
Don't forget you can also use a subquery instead of a values list, so I'm not sure how your example address that scenario...
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;





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