[ch 5] Syntax Error in Sql Statement XD

Discuss topics concerning this volume

Moderators: Fringe Security Bureau, Senior Editors, Senior Translators, Alt. Language Translator/Editor, Executive Council, Project Translators, Project Editors

Locked
User avatar
onizuka-gto
Editor-in-Chief
Posts: 4840
Joined: Wed May 10, 2006 9:02 pm
Favourite Light Novel: Suzumiya Haruhi
Mahouka koukou no Rettousei
No Game No Life
Mushoku Tensei
Mother of Learning
Location: N.E.E.T Federation
Contact:

[ch 5] Syntax Error in Sql Statement XD

Post by onizuka-gto »

Syntax Error in Sql Statement XD

i think there should be a _ between continuity code as it's an syntax error X_X WHERE code=information should be WHERE code='information' um.. that should be it XD

SELECT continuity_code
FROM databank
WHERE code='information'
ORDER BY aggressive_combat_data
HAVING END_MODE
It seems it has been changed again... however the quotes around information weren't added and the condition PERSONAL NAME Asakura Ryouko was added.
SELECT continuity, code
FROM databank
WHERE code=information
ORDER BY aggressive_combat_data
HAVING end_mode
PERSONAL NAME Asakura Ryouko

In any case, in SQL syntax there is no such thing as a PERSONAL NAME modifier (and in any case, Asakura Ryouko would have to be enclosed between quotes). The usage of HAVING is incorrect as well, since the HAVING must be used in conjuction with a GROUP BY statement (which is not present) and it must be followed by a condition (normally an arithmetic one)...however it is such a trivial issue that it might not be worth correcting, but what do other people think about it? Was it like that in the original version? If that's the case, it might not be worth correcting -Proto 1:14, 1 May 2006 (Central)


Odd, I'm looking at the original text, and it seems to be more like this:
SELECT serial_code
FROM database
WHERE code='data'
ORDER BY aggressive_combat_data
HAVING terminate_mode
"Target name Asakura Ryoko, hostility confirmed[...]"

I'm going to make the change, but if it seems wrong, feel free to change it back.

--Kumarei 12:27, 8 May 2006 (EST)


I'd just like to comment that HAVING is used incorrectly, however not as was previously stated. HAVING does not need to be used in conjunction with a GROUP BY statement. HAVING is only used when doing boolean compairisons on an aggregate function returned by the select. In most cases this means that the GROUP BY statement is there because if you select anything aside from the aggregate function, the GROUP BY is required to make it work. If you were only selecting the aggregate function however, then there would be no GROUP BY, and the HAVING caluse would be valid (Albeit stupid since you're only getting 1 number returned by the select, and running a HAVING boolean check on 1 number would be useless).

Anyways, the HAVING clause is incorrect because the only time you use HAVING is when running a boolean compairison on an aggregate function. It's a WHERE statement for aggregate functions.

Example
SELECT X, sum(y) as total
FROM table
WHERE x = 2
GROUP BY X
HAVING total > 5
That's an appropriate use of HAVING because it's running a compairison on the aggregate function sum(y). Only in situations such as this one is HAVING a valid statement. In any other situations, the comparision would be contained in the WHERE portion of the statement.

-Seigfreid
User avatar
Kinny Riddle
Senior Project Translator
Posts: 653
Joined: Sat May 13, 2006 11:54 am
Favourite Light Novel:

Post by Kinny Riddle »

In the original text, "PERSONAL NAME" is actually one of Yuki's commands. Remember, Yuki's commands may be very similar to SQL, but it is NOT completely SQL.
Image
dogtato
Mikuru's Master
Posts: 27
Joined: Fri May 12, 2006 11:08 pm
Favourite Light Novel:

Post by dogtato »

it doesn't really make a lot of sense anyways

Code: Select all

SELECT serial_code
alright, select serial_code

Code: Select all

FROM database
what, it's all just in a single database? I guess she's smart but this seems inefficient.

Code: Select all

WHERE code='data'
why would an attribute called code have a value of "data". what does that even mean?

Code: Select all

ORDER BY aggressive_combat_data
ok i guess asakura ryouko is expected to be at or near the top

Code: Select all

HAVING terminate_mode
again, no GROUP BY. also, isn't HAVING supposed to be followed by a condition? (I got a D in that class so I don't remember so well)

so yeah, might as well pretend it's just Yuki's improved personal version of SQL
Locked

Return to “Volume 1 - The Melancholy of Suzumiya Haruhi / 第一巻: 涼宮ハルヒの憂鬱”