数据库
首页 > 数据库> > Doris与mysql语法对照,差异篇

Doris与mysql语法对照,差异篇

作者:互联网


## SQL语法差异:

### doris中不支持分组列再使用distinct

MSYQL:

```SQL
select DISTINCT mid from order_card_detail GROUP BY mid
```

DORIS:

```SQL
select mid from order_card_detail GROUP BY mid
```

doris执行异常:[Err] 1064 - errCode = 2, detailMessage = cannot combine SELECT DISTINCT with aggregate functions or GROUP BY



### mysql中 where后可直接 locate() 判断,doris中需判断

MYSQL:

```sql
select mid from order_card_detail where LOCATE(mid,'4')
```



DORIS:

```SQL
select mid from order_card_detail where LOCATE(mid,'4')>0
```

doris执行异常:[Err] 1064 - errCode = 2, detailMessage = WHERE clause requires return type 'BOOLEAN'. Actual type is 'INT'.



### doris 中编写sql不支持 #注释

MYSQL:

```SQL
#1233
select * from hopsonone_point.members_points_detail limit 100
```



DORIS:

```sql
--1233
select * from hopsonone_point.members_points_detail limit 100
```

doris执行异常:[Err] 1064 - errCode = 2, detailMessage = Please check your sql, we meet an error when parsing.



### mysql中支持部分多表联查分组后跟部分字段,doris需将非聚合查询字段都放在分组条件后

MYSQL:

```SQL
SELECT m_id,behavior,SUM(point)
FROM (
select m_id,behavior,point from hopsonone_point.members_points_detail limit 100
) t1
GROUP BY m_id;
```



DORIS:

```sql
SELECT m_id,behavior,SUM(point)
FROM (
select m_id,behavior,point from hopsonone_point.members_points_detail limit 100
) t1
GROUP BY m_id,behavior;
```

doris执行异常:[Err] 1064 - errCode = 2, detailMessage = select list expression not produced by aggregation output (missing from GROUP BY clause?): `behavior`

标签:point,detail,mid,语法,Doris,behavior,mysql,id,doris
来源: https://www.cnblogs.com/xyz01/p/15771261.html