当前位置:网站首页>Problem recording and thinking
Problem recording and thinking
2022-06-25 23:20:00 【newProxyInstance】
Preface : Daily problem recording and thinking .
Mysql Group by sentence
Study group by The first thing to know is What are aggregate functions ? What are the aggregation functions ?
Most common usage , Check the minimum specifications for each product .
SELECT
goods_id,
min( goods_price )
FROM
tb_sku_info
GROUP BY
goods_id
But we may need other fields such as id perhaps name wait , An error may be reported when querying non aggregated columns , For example, the following statement .
SELECT
id,
goods_id,
min( goods_price )
FROM
tb_sku_info
GROUP BY
goods_id
Inquire about sql_mode sentence
select @@sql_mode
set @@sql_mode = ONLY_FULL_GROUP_BY
select * from config_info group by group_id
1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column
'nacos_config.config_info.id' which is not functionally dependent on columns in GROUP BY clause;
this is incompatible with sql_mode=only_full_group_by
Remove sql_mode in ONLY_FULL_GROUP_BY This specification is incorrect , If you don't pay attention, it will cause other problems .
The most obvious is Wrong line problem .
SELECT
id,
specifications,
goods_id,
min( goods_price )
FROM
tb_sku_info
GROUP BY
goods_id
The query results are shown in the figure

After querying the general table, you can see that the price in the red box is the lowest price of goods .

Correct writing , Query through a link , use The lowest price is id Two Field to uniquely match row records in the main table .
SELECT
*
FROM
tb_sku_info AS t1
INNER JOIN ( SELECT goods_id, min( goods_price ) AS mixPrice FROM tb_sku_info GROUP BY goods_id ) AS t2 ON t1.goods_id = t2.goods_id
AND t1.goods_price = t2.mixPrice

边栏推荐
- Applets - view and logic
- 实战:typora里面如何快捷改变字体颜色(博客分享-完美)-2022.6.25(已解决)
- Baidu: in 2022, the top ten hot spots will rise and the profession will be released. There is no suspense about the first place!
- App test points
- Oracle -- table operation
- 一位博士在华为的22年
- 民航局:到 2025 年我国将初步建成安全、智慧、高效和绿色的航空物流体系
- 1281_FreeRTOS_vTaskDelayUntil实现分析
- 2022 love analysis · panoramic report of it operation and maintenance manufacturers
- 【EOSIO】EOS/WAX签名错误 is_canonical( c ): signature is not canonical 问题
猜你喜欢

电路模块分析练习5(电源)

Use and difference between ue4\ue5 blueprint node delay and retroggable delay

一位博士在华为的22年

Basic concepts of processor scheduling
![[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[eosio] eos/wax signature error is_ Canonical (c): signature is not canonical

Oracle - getting started

Fastjson deserialization randomness failed

多模态数据也能进行MAE?伯克利&谷歌提出M3AE,在图像和文本数据上进行MAE!最优掩蔽率可达75%,显著高于BERT的15%...

Oracle - 基本入门

Kubernetes cluster construction of multiple ECS
随机推荐
Does jQuery cache any selectors- Does jQuery do any kind of caching of “selectors”?
Flex & Bison 開始
Trillions of hot money smashed into the space economy. Is it really a good business?
UE4_ Ue5 combines the offline voice recognition plug-in for speech recognition
Fastjson deserialization randomness failed
Unity技术手册 - 生命周期内颜色ColorOverLifetime--速度颜色ColorBySpeed
.sql数据库导入错误:/*!40101 SET @[email protected]@COLLATION_CONNECTION */
C language and the creation and use of database
电路模块分析练习5(电源)
What is 5g? What can 5g do? What will 5g bring in the future?
如何用jmeter做接口测试
As a programmer, how can we learn, grow and progress happily? (personal perception has nothing to do with technology)
The applet draws a simple pie chart
How to disable the optical drive
Why is the frame rate calculated by opencv wrong?
No absurd tea applet - rule change
Intimacy - [comfortable exit] - final communication to reduce injury
Thinking while walking
Why absolute positioning overlaps
电路模块分析练习6(开关)