【问题标题】:Update syntax right but zero rows affected MySQL正确更新语法但零行影响 MySQL
【发布时间】:2013-02-26 14:07:36
【问题描述】:

这是我的数据:

表税1

tax           | tax_list

abc_132       | empty   
cda_456       | empty    
akc_896       | empty 

表属

taxon_list    | taxon_schema

Bees          | abc_132 cda_456    
Elefants      | akc_896

现在我想用表 GENUS 中的 taxon_list 填充表 TAX1 中的空 tax_list,其中表 TAX1 中的税项出现在 TABLE GENUS 的 taxon_schema 中。

我尝试了以下解决方案;语法似乎是正确的,但我得到“0行影响”因此没有任何变化!

update Tax1 set Tax1.tax_list=(select genus.taxon_list from genus where Tax1.tax_schema like concat('%genus.taxon_schema%'));

应该是这样的:

tax                  |    tax_list

abc_132              | Bees    
cda_456              | Bees
akc_896              | Elefants 

【问题讨论】:

  • 你在运行什么 DBMS?
  • MySQL - 抱歉信息不足:(
  • Tax1.tax_schema,应该是Tax1.tax吗?还是有别的领域?

标签: mysql rows concat


【解决方案1】:

试一试。

update Tax1
  set Tax1.tax_list=(
    select genus.taxon_list from genus where genus.taxon_schema like concat('%', Tax1.tax, '%'));

变化:

此外,您可能希望将 LIMIT 1 添加到选择中,以防它匹配 > 1 行。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-11-22
    • 2017-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-22
    • 2014-06-02
    相关资源
    最近更新 更多