gpt4 book ai didi

mysql - 如何为此编写查询?

转载 作者:太空宇宙 更新时间:2023-11-03 11:13:49 25 4
gpt4 key购买 nike

嗨, friend 们,我有一张这样的 table

ID  bid   sub_bid  cid  sub_cid1    0       2      1       02    5       0      3       03    3       0      0       44    2       0      4       0

在该表上,(bid 或 sub_bid)或(cid 或 sub_cid)将为空。我必须写一个这样的查询..如果出价为零,那么我必须接受 sub_bid 或 sub_bid 为零,那么我必须接受出价同样的 cid 也。

如何在我的 mysql 查询中给出这种条件。任何人都可以帮助我。谢谢

最佳答案

看看 CASE WHEN 语句:

   SELECT
CASE WHEN bid is NULL or bid = 0
sub_bid
ELSE
bid end
as abid

http://dev.mysql.com/doc/refman/5.0/en/case-statement.htmlhttp://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html

关于mysql - 如何为此编写查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6691394/

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