UPDATE goods_copy1 SET supplier_id = temp.supplier_id FROM goods_copy1 g1 INNER JOIN ( SELECT gpd.file_id, gpd.goods_id, im.supplier_id, g.supplier_id supplier_id2 FROM import_file im LEFT JOIN `goods_ppt_details` gpd ON gpd.file_id = im.file_id LEFT JOIN goods_copy1 g ON gpd.goods_id = g.goods_id WHERE gpd.tenant_id = 174 AND g.is_delete = '2' AND im.supplier_id != 0 AND g.supplier_id = 0 GROUP BY gpd.goods_id ) temp ON temp.goods_id = g1.goods_id这个执行不成功是什么问题
时间: 2024-01-16 22:05:28 浏览: 141
这个 SQL 语句的问题可能是在 `UPDATE` 子句中没有指定要更新的表别名。你可以尝试以下修改:
```
UPDATE goods_copy1 g1
SET g1.supplier_id = temp.supplier_id
FROM (
SELECT gpd.goods_id, im.supplier_id
FROM import_file im
LEFT JOIN goods_ppt_details gpd ON gpd.file_id = im.file_id
LEFT JOIN goods_copy1 g ON gpd.goods_id = g.goods_id
WHERE gpd.tenant_id = 174 AND g.is_delete = '2' AND im.supplier_id != 0 AND g.supplier_id = 0
GROUP BY gpd.goods_id
) temp
WHERE temp.goods_id = g1.goods_id;
```
这里使用了别名 `g1` 指定要更新的表,同时将子查询的结果用作临时表来更新 `goods_copy1` 表。
相关问题
import netCDF4 import geopandas as gpd import numpy as np import pandas as pd # 加载nc文件 nc_file = netCDF4.Dataset('E:/data/temp_CMFD_V0106_B-01_01mo_010deg_197901-201812.nc') temp_data = nc_file.variables['temp'][:] # 加载shp文件 shp_file = gpd.read_file('D:/dilidashuju/shijiquhua.shp') # 计算每个市级行政区的平均温度 years = range(1979, 2018) months = range(1, 13) temp_df = pd.DataFrame(columns=['year', 'month', 'city', 'temperature']) for year in years: for month in months: temp_array = temp_data[(year-1979)*12+month-1, :, :] for i, row in shp_file.iterrows(): city_name = row['市'] city_geom = row['geometry'] temp_mean = np.mean(temp_array[np.array([city_geom.contains(Point(lon, lat)) for lon, lat in zip(temp_array.lon, temp_array.lat)])]) temp_df = temp_df.append({'year': year, 'month': month, 'city': city_name, 'temperature': temp_mean}, ignore_index=True) # 将结果保存到CSV文件中 temp_df.to_csv('city_temperature.csv', index=False)这串代码报错Traceback (most recent call last): File "C:\Users\Lenovo\PycharmProjects\pythonditu\main.py", line 24, in <module> temp_mean = np.mean(temp_array[np.array([city_geom.contains(Point(lon, lat)) for lon, lat in zip(temp_array.lon, temp_array.lat)])]) AttributeError: 'MaskedArray' object has no attribute 'lon'怎么修改
这个错误是因为 `temp_array` 是一个 `MaskedArray` 对象,它不能像普通的 numpy 数组那样直接使用索引访问变量。要解决此错误,可以使用 `data` 属性来访问 `temp_array` 的实际数据数组,如下所示:
```
temp_mean = np.mean(temp_array.data[np.array([city_geom.contains(Point(lon, lat)) for lon, lat in zip(temp_array.lon, temp_array.lat)])])
```
这将使用列表推导式为 `temp_array` 中的每个点创建一个包含 True 或 False 的数组,并将其传递给 `temp_array.data`,以便获取在 `city_geom` 中的温度值。
代码含义 sns.set_style("whitegrid") world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')) world = world[world.continent != 'Antarctica'] world_map = pd.merge(world, right=countries_rank, how='left', on='iso_a3').fillna(0) fig, ax = plt.subplots(figsize=(12,12)) ax.set_xticks([]) ax.set_yticks([]) ax.set_title("每个国家的评估计数",fontproperties="SimHei", size=16) world_map.drop(159).plot(column='count_log', cmap='Blues', linewidth=0.8, ax=ax, edgecolor='0.8') sns.set() plt.box(on=None) plt.show()
这段代码的含义是:
1. 设置 seaborn 库的样式为 "whitegrid"。
2. 从 GeoPandas 库中读取全球地图数据,并去除南极洲的大陆。
3. 将全球地图数据和国家评估计数数据进行合并,并用 0 填充缺失值。
4. 创建一个大小为 12x12 的绘图对象和对应的坐标轴,并设置坐标轴的标题为 "每个国家的评估计数"。
5. 从数据中删除索引为 159 的行,并在世界地图上绘制每个国家的评估计数数据,使用蓝色调色板 cmap='Blues',线宽为 0.8,边缘颜色为 '0.8'。
6. 设置 seaborn 库的默认样式。
7. 隐藏图框。
8. 显示绘制的图形。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)