gpt4 book ai didi

mysql - 字符串 1 - 结果 1 - 字符串 2 - 结果 2

转载 作者:太空宇宙 更新时间:2023-11-03 11:51:00 27 4
gpt4 key购买 nike

所以我需要找出一个可能会打印出如下示例的句子的查询:

"The most expensive item is Apple and the cheapest item is LG"

Example table: 
+---------+-------+---------+
| item | price | inStock |
+---------+-------+---------+
| Samsung | 55 | 40 |
| Apple | 80 | 45 |
| LG | 45 | 25 |
+---------+-------+---------+

这是我目前所拥有的,但我的打印输出是这样的:

SELECT GROUP_CONCAT('The most expensive item is ', item SEPARATOR ' and the
cheapest item is ')
FROM table_name
WHERE price=(SELECT MAX(price) FROM table_name) OR price=(SELECT MIN(price) FROM table_name)
GROUP BY 'all';

"The most expensive item is Apple and the cheapest item is, The most expensive item is LG and the cheapest item is"

最佳答案

试试这个查询:

SELECT CONCAT('The most expensive item is ',
(SELECT item
FROM yourTable
WHERE price = (SELECT MAX(price) from yourTable)),
' and the cheapest item is ',
(SELECT item
FROM yourTable
WHERE price = (SELECT MIN(price) from yourTable)))

关于mysql - 字符串 1 - 结果 1 - 字符串 2 - 结果 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35558938/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com