Doris与mysql语法对照,差异篇

2022/1/6 19:35:10

本文主要是介绍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`



这篇关于Doris与mysql语法对照,差异篇的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程