select i_wxp_identifier, case i_pay_source when 1 then 小程序 when 2 then 微官网 else pc end as source from t_wei_xin_pay为什么不对呢
时间: 2024-04-07 20:31:17 浏览: 22
从语法上看,这个 SQL 查询语句是没有问题的。它的作用是从表 `t_wei_xin_pay` 中选择 `i_wxp_identifier` 和 `i_pay_source` 字段,并将 `i_pay_source` 字段的值映射为 `source` 字段的值,其中当 `i_pay_source` 的值为 1 时,`source` 字段的值为 "小程序",当 `i_pay_source` 的值为 2 时,`source` 字段的值为 "微官网",否则 `source` 字段的值为 "pc"。
如果你认为这个 SQL 查询语句不对,可能是因为你期望它的结果与实际不符。你可以检查一下数据表中的数据,看一下是否符合你的预期。另外,你也可以提供更详细的信息,让我更好地帮助你解决问题。
相关问题
select i_wxp_identifier, case w.dt_pay_time when is not null then 1 else null end as is_succeed from t_wei_xin_pay写的对吗
这个 SQL 查询语句有一些问题,可能存在语法错误。首先,SELECT 和 FROM 关键字之间应该指定需要查询的列名或使用通配符 *。其次,CASE 表达式中的关键字 WHEN 后面应该跟具体的条件表达式,表示在满足该条件时返回对应的值。最后,查询语句应该以分号 ; 结尾,表示语句的结束。
基于以上问题,可以尝试重新编写该查询语句,例如:
```
SELECT i_wxp_identifier,
CASE WHEN w.dt_pay_time IS NOT NULL THEN 1 ELSE NULL END AS is_succeed
FROM t_wei_xin_pay w;
```
该语句将返回 `t_wei_xin_pay` 表中的 `i_wxp_identifier` 列和一个新的名为 `is_succeed` 的列。当 `dt_pay_time` 列不为 NULL 时,该列的值为 1,否则为 NULL。注意,该语句的正确性还要基于具体的数据表结构和业务需求进行验证。
[ERROR]: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
这个错误是由于表中的字符集不一致所导致的。您可以按照以下步骤来解决这个问题:
1. 首先,您可以查询表中的排序规则来找出不一致的字符集:
```
SELECT table_schema, table_name, column_name, character_set_name, collation_name
FROM information_schema.columns
WHERE collation_name = 'utf8_general_ci'
OR collation_name = 'utf8mb4_general_ci';
```
这个查询将返回具有不一致字符集的表和列的信息。
2. 根据查询结果,您可以使用ALTER TABLE语句来修改表的字符集:
```
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
```
这将把表的字符集修改为utf8mb4,并使用utf8mb4_general_ci排序规则。
3. 如果您发现有其他不一致的字符集,您可以使用类似的ALTER TABLE语句来修改它们。
通过执行这些步骤,您应该能够解决这个字符集不一致的错误。请记得在执行任何数据库操作之前备份您的数据。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [java.sql.SQLException: Illegal mix of collations (utf8mb4_general_ci,IMPLICIT) and (utf8mb4_0900_ai_](https://blog.csdn.net/gys9895/article/details/128342949)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [mysql:Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT)](https://blog.csdn.net/wxp0624/article/details/109611894)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)