1

我需要使用来自其他名为 azz_locality(字段名称为“名称”)和 azz_category(字段名称也是“名称”)的表中的值来更新名为 azz_properties 的表中名为“tipos”的字段,并使用单词来分隔这些值, “在”这个词。基本上我需要创建一个迷你描述短语,例如“物业区域中的物业类别”,例如。在罗马的房子。

此外,只有当它为空时,我才需要更新该值。

我尝试了以下代码,但收到“0行受影响”

update azz_properties p join
   azz_locality l
   on p.id = l.id join
   azz_category c
   on p.id = c.id
set p.tipos = concat(c.name, ' in ', l.name);

任何人都可以帮助我吗?我究竟做错了什么?

下面是每个表中的一些行,我试图以一种很好的方式使其可见,但这是我能做的最好的,对不起......:

表 azz_category

id  name    alias   parent  published   ordering
17  Apartamentos    apartamentos    0   1   0
18  Casas   casas   0   1   1
19  Casas em condominios    casas-em-condominios    0   1   2
20  Coberturas  coberturas  0   1   3

表 azz_locality

id  parent  mid     zipcode     name    alias   published   ordering    checked_out     checked_out_time
1   1   0   0   Abraão  abraao  1   0   0   0000-00-00 00:00:00
2   1   0   0   Armação     armacao     1   0   0   0000-00-00 00:00:00
3   1   0   0   Agronômica  agronomica  1   0   0   0000-00-00 00:00:00
5   1   0   0   Bairro de Fatima    bairro-de-fatima    1   0   0   0000-00-00 00:00:00
6   1   0   0   Balneário Estreito  balneario-estreito  1   0   0   0000-00-00 00:00:00
7   1   0   0   Barra da Lagoa  barra-da-lagoa  1   0   0   0000-00-00 00:00:00
9   1   0   0   Beira Mar   beira-mar   1   0   0   0000-00-00 00:00:00
10  1   0   0   Bela Vista  bela-vista  1   0   0   0000-00-00 00:00:00
168     19  0   0   Siriú   siriu   0   0   0   0000-00-00 00:00:00

这是 azz_properties,其中类别 id 是“cid”字段,位置 id 是“lid”

id  name    name_tipos  name_barrios    alias   parent  agent_id    agent   ref     type    cid     lid     sid     cyid    postcode    address     description     text    text_es     text_en     text_barrios    tipos   price   published   use_booking     ordering    panoramic   video   lat     lng     available   featured    years   bedrooms    bathrooms   garage  area    covered_area    hits    listdate    refresh_time    checked_out     checked_out_time 
2920    Vendo Apartamento...    Vendo Apartamento...        vendo-apartamento...    0   62      A3044   62  17  3   1   1       Rua Silveira    Agenciamento...     <p>Apartamento ...  360000.00   1   0   0   NULL        0.000000    0.000000    0   0   2012.01.01.05110    3   2   1   105     90  231     2013-05-03  2013-05-03 00:00:00     0   0000-00-00 00:00:00      
4

1 回答 1

1

给定数据,您似乎需要的是:

update azz_properties p join
   azz_locality l
   on p.lid = l.id join
   azz_category c
   on p.cid = c.id
set p.tipos = concat(c.name, ' in ', l.name);
于 2013-09-29T19:45:02.003 回答