gpt4 book ai didi

mysql - SQL 查询的 WHERE 子句中的 CASE 语句

转载 作者:可可西里 更新时间:2023-11-01 08:47:10 26 4
gpt4 key购买 nike

我想编写一个查询,在运行时根据条件构造 WHERE 子句。这是我想要做的。

SELECT name from data_table WHERE 
CASE
WHEN input_data = location THEN <where condition should be based on location>
WHEN input_data = college THEN <where condition should be based on college name>

我该怎么做呢?可能吗?

最佳答案

SELECT name from data_table
WHERE (input_data = location AND condition based on location)
OR (input_data = college AND condition based on college name)

关于mysql - SQL 查询的 WHERE 子句中的 CASE 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25399226/

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