Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 是否可以将这两个SQL查询更改为1?_Mysql - Fatal编程技术网

Mysql 是否可以将这两个SQL查询更改为1?

Mysql 是否可以将这两个SQL查询更改为1?,mysql,Mysql,是否可以将这两个查询更改为1 问题1: 更新“pvdownloader”。“posts` 集合'exists`='y' 其中source=从dbdownloader.posts中选择任何源 和“mangacount”=0 而不是'exists`='m' 问题2: 更新“pvdownloader”。“posts` 集合“存在”='n' 其中'exists`='u' 和“mangacount”=0 我假设用IF/ELSE可以制作这样的东西,但我根本不知道如何使用它:也许类似的东西可以工作: upda

是否可以将这两个查询更改为1

问题1:

更新“pvdownloader”。“posts` 集合'exists`='y' 其中source=从dbdownloader.posts中选择任何源 和“mangacount”=0 而不是'exists`='m' 问题2:

更新“pvdownloader”。“posts` 集合“存在”='n' 其中'exists`='u' 和“mangacount”=0
我假设用IF/ELSE可以制作这样的东西,但我根本不知道如何使用它:也许类似的东西可以工作:

update
  pvdownloader.posts
set
  exists =
    case
      when source = any(select source from dbdownloader.posts) and mangacount = 0 and exists != 'm' then 'y'
      when exists = 'u' and mangacount = 0 then 'n'
    end
where 
  (source = any(select source from dbdownloader.posts) and mangacount = 0 and exists != 'm')
  or
  (exists = 'u' and mangacount = 0)
;

正如@MostyMostacho所建议的,我冒昧地更改了您的逻辑,使其不具有双重否定。

也许类似的方法会奏效:

update
  pvdownloader.posts
set
  exists =
    case
      when source = any(select source from dbdownloader.posts) and mangacount = 0 and exists != 'm' then 'y'
      when exists = 'u' and mangacount = 0 then 'n'
    end
where 
  (source = any(select source from dbdownloader.posts) and mangacount = 0 and exists != 'm')
  or
  (exists = 'u' and mangacount = 0)
;

正如@MostyMostacho所建议的,我冒昧地更改了您的逻辑,使其不具有双重否定。

逻辑表示,而不是mangacount=0与AND mangacount=0相同:您可以尝试语句。哦,从来没有想过xDLogic所说的,而不是mangacount=0与和mangacount=0相同:您可以尝试语句。哦,从来没有想过xDWorks是完美的,与我所希望的使用两个查询相比,速度提高不了多少:是的,我不可能称之为快速操作。如果使用where子句,它必须进行两次内部选择,您应该这样做。它还必须对表中的每一行运行该案例比较。如果MySQL支持子句,速度会快一点,但遗憾的是,它并不完美,与我所希望的使用两个查询相比,速度提高不了多少:是的,我不可能称之为快速操作。如果使用where子句,它必须进行两次内部选择,您应该这样做。它还必须对表中的每一行运行该案例比较。如果MySQL支持子句,速度会快一点,但遗憾的是,它没有。