Having a little bit of a difference between Oracle and MySQL

Source: Internet
Author: User

In Oracle, the having must be used in conjunction with group by, but in MySQL the situation is different and can be used alone.

C:\Documents and Settings\guogang>sqlplus Test/test

Sql*plus:release 10.2.0.1.0-production on Tuesday August 12 09:09:58 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connect to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-64bit Production
With the partitioning, OLAP, Data Mining and Real application testing options

Sql> SELECT * from test1 has owner = ' SYS ';
SELECT * from test1 have owner = ' SYS '
*
An error occurred on line 1th:

ORA-00979: Not a GROUP by expression


Sql> Select Owner,count (1) from the Test1 group by owner has the owner = ' SYS ';
OWNER COUNT (1)
------------------------------ ----------

SYS 30754


Mysql> SELECT * FROM Test have id>98;
+------+-------------+
| ID | Create_time |
+------+-------------+
| 99 | 2014-08-12 |
| 100 | 2014-08-12 |
+------+-------------+
2 rows in Set (0.00 sec)

mysql> Select Id,count (1) has id>98 from the test group by ID;
+------+----------+
| ID   | COUNT (1) |
+------+----------+
|   |        1 |
|  100 |        1 |
+------+----------+
2 rows in Set (0.00 sec)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.