Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 "Features" not bugs?
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Zeroth




PostPosted: Wed Sep 24, 2008 7:49 pm   Post subject: "Features" not bugs?

So, I've been taking COSC 304, Intro to Databases, and we had a very... interesting experience with MySQL.

Take, for example, this query,
SQL:

SELECT   title, COUNT(eno) AS numEmp,
         MIN(salary) as minSal,
         MAX(salary) as maxSal, AVG(salary) AS avgSal
FROM     emp
GROUP BY title;

(for reference, here is the basic DDL for the tables:
emp (eno, ename, bdate, title, salary, supereno, dno)
proj (pno, pname, budget, dno)
dept (dno, dname, mgreno)
workson (eno, pno, resp, hours))

Now, so, he decided to show us a sample of erroneous selects, and did this:
SQL:

SELECT   ename, COUNT(eno) AS numEmp,
         MIN(salary) as minSal,
         MAX(salary) as maxSal, AVG(salary) AS avgSal
FROM     emp
GROUP BY title;

And MySQL accepted it. It even pulled out names... which would not be unique per group! Funnily enough SQLServer did not accept this input. Even worse, these two queries were both accepted, and returned a column of 5's.
SQL:

SELECT   ename+5, COUNT(eno) AS numEmp,
         MIN(salary) as minSal,
         MAX(salary) as maxSal, AVG(salary) AS avgSal
FROM     emp
GROUP BY title;

SELECT   ename+'5', COUNT(eno) AS numEmp,
         MIN(salary) as minSal,
         MAX(salary) as maxSal, AVG(salary) AS avgSal
FROM     emp
GROUP BY title;


...This was pretty shocking to us, needless to say.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: