-1

我有两张表,内容如下:

table 1
sid, schedule, stime, splace, stourid

table 2
tourid, tourname

我想table 1在 GridView 中显示 ,但stourid我希望显示的字段是tournamefromtable 2而不是stourid. 我怎样才能做到这一点?

4

5 回答 5

1

假设上面的 stourid 是指向表 2 的指针并映射到 tourid,我将创建一个带有 tourid/stourid 连接的视图并显示该视图。就像是:

CREATE VIEW myView
AS
SELECT sid, schedule, stime, splace, tourname
FROM
[table 1] AS t1 
JOIN [table 2] AS t2
ON t1.stourid = t2.tourid
于 2012-09-03T12:35:46.040 回答
0

对您的数据执行以下 SQL 语句,将结果绑定到您的表并仅显示您想要显示的列。

select * from table1 join table2 on table1.tourid = table2.tourid
于 2012-09-03T12:29:34.453 回答
0

您可以使用Join查询:

SELECT sid, schedule, stime, splace, tourname
FROM table1 INNER JOIN table2 ON table1.stourid = table2.tourid
于 2012-09-03T12:31:27.087 回答
0

使用内连接...

select t1.sid,t1.schedule,t1.stime,t1.splace,t2.tourname from table1 t1 inner join table2 t2 on t1.tourid = t2.tourid 
于 2012-09-03T12:33:21.720 回答
0

SELECT sid, schedule, stime, splace, tourname FROM table1 交叉连接表2

于 2012-09-03T12:34:46.687 回答