gpt4 book ai didi

mysql - SQL 查询 - C# 数据库连接 (DataGrid)

转载 作者:行者123 更新时间:2023-11-29 12:39:27 26 4
gpt4 key购买 nike

我正在尝试使用 SQL 查询从 2 个表中获取信息..

SELECT Num_of_icon, ID_Radar, ID_Observer,
Longitude_Impact_point, Latitude_Impact_point,
Longitude_Impact_point_By_Cutting, Latitude_Impact_point_By_Cutting,
Deviation_In_Meters,
Longitude_Deviation, Latitude_Deviation,
Longitude, Latitude, Azimuth
FROM ShowTable, Observer
ORDER BY Num_of_icon ASC

Num_of_icon 是一个表中的键。
ID_Observer 是第二个表中的键,第一个表中的字段。

错误是:

The field 'ID_Observer' should be show in more than one table.

我不明白这个错误是关于什么的。我知道 ID_Observer 显示多个表,这就是为什么我在表之间有连接...

最佳答案

如果两个表中存在某个列,则必须使用tablename.columnname 限定该列。您还必须通过 JOIN 链接两个表:

SELECT Num_of_icon, 
ID_Radar,
SHowTable.ID_Observer, --<<< HERE
Longitude_Impact_point,
Latitude_Impact_point,
Longitude_Impact_point_By_Cutting,
Latitude_Impact_point_By_Cutting,
Deviation_In_Meters,
Longitude_Deviation,
Latitude_Deviation,
Longitude,
Latitude,
Azimuth
FROM ShowTable
INNER JOIN Observer
ON ShowTabl.ID_Observer = Observer.ID_Observer --<<< and HERE
ORDER BY Num_of_icon ASC

关于mysql - SQL 查询 - C# 数据库连接 (DataGrid),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26319536/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com