我有两张表格如下:
table 1
sid, schedule, stime, splace, stourid
table 2
tourid, tourname
我想在GridView中显示table 1
,但使用字段stourid
,我希望tourname
显示table 2
而不是stourid
。我怎么能这样做?
答案 0 :(得分: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
答案 1 :(得分:0)
对您的数据执行以下SQL语句,将结果绑定到您的表并仅显示您想要显示的列。
select * from table1 join table2 on table1.tourid = table2.tourid
答案 2 :(得分:0)
您可以使用Join
查询:
SELECT sid, schedule, stime, splace, tourname
FROM table1 INNER JOIN table2 ON table1.stourid = table2.tourid
答案 3 :(得分:0)
使用内部加入...
select t1.sid,t1.schedule,t1.stime,t1.splace,t2.tourname from table1 t1 inner join table2 t2 on t1.tourid = t2.tourid
答案 4 :(得分:0)
SELECT sid,schedule,time,space,tourname FROM table1交叉连接 table2