我需要在名为azz_properties的表中更新名为“tipos”的字段,其中包含名为azz_locality(字段名称为“name”)和azz_category(字段名称也是“name”)的其他表中的值,使用单词分隔那些价值观,单词“in”。基本上我需要创建一个迷你描述短语,如“物业地点中的物业类别”,例如。在罗马的房子。
另外,我只需要在值为空时更新值。
我尝试了以下代码,但收到“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,其中category id是“cid”字段,locality 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
答案 0 :(得分: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);