C# 使用c从mysql中的3个不同表中获取数据

C# 使用c从mysql中的3个不同表中获取数据,c#,mysql,C#,Mysql,我在mysql中有3个表 theatredet(theatid,theatname,locid) location(locid,locname) screendet(scname,theatid,seats avail) 我想从Theateredet获得完整的表值, 需要根据locid从第二个表中获取locname 需要获得座位可用,scname从第三个表格中以ATID为基础 如何使用c在单个查询中实现这可能会对您有所帮助 Select td.*, l.locname, sd.seats_av

我在mysql中有3个表

theatredet(theatid,theatname,locid)
location(locid,locname)
screendet(scname,theatid,seats avail)
我想从Theateredet获得完整的表值, 需要根据locid从第二个表中获取locname 需要获得座位可用,scname从第三个表格中以ATID为基础 如何使用c在单个查询中实现这可能会对您有所帮助

Select td.*, l.locname, sd.seats_avail, sd.scname 
From theatredet td, location l, screendet sd
WHERE l.locid = 1 AND sd.theatid = 1
您可以将1替换为您想要用作条件的数字。

尝试SQl内部联接


选择Theateredet.*,location.locname,screendet.scname,screendet.seats可从Theateredet上的Theateredet内部连接位置使用。locid=location.locid-internal-join-screendet-on-screendet.theatid这是sql语句:

Select theatredet.*, locname, avail, scname
From theatredet 
Inner Join location ON location.locid = theatredet.locid
Inner Join screendet ON screendet.theatid = theatredet.theatid;
但是您需要将MySql连接器绑定到您的项目。看看这个:
下面是如何使用C中的连接器:

请提供您尝试过的代码和已有的代码?如果没有任何代码,我们就无法正确地帮助您。@Roman:我还没有试过?我需要代码..好吧,请注意StackOverflow不是要求您没有代码的地方。如果您有任何问题,请寻求帮助,具体取决于您的代码。代码是什么?对不起,它们是最高机密,以防止未经授权的导弹发射