我有2个表tbl_issued和tbl_transaction。

tbl_issued的列为ItemID,Item,Serial,Quantity和Size。尽管tbl_transaction的列为Released,Received,Approved和Department

我的问题是我想在1查询中获取其列,这是mysql查询

SELECT `ItemID`,`Item`,`Serial`,`Quantity`,`Size`,`Class`,`Unit`,(SELECT `Released`  FROM `tbl_transaction` WHERE `TransactionID` = 12458952) AS `Released`,
(SELECT `Received`  FROM `tbl_transaction` WHERE `TransactionID` = 12458952) AS `Received`,
(SELECT `Approved`  FROM `tbl_transaction` WHERE `TransactionID` = 12458952) AS `Aprroved`,
(SELECT `Department`  FROM `tbl_transaction` WHERE `TransactionID` = 12458952) AS `Department`
FROM `tbl_issued` WHERE `TransactionID` =  12458952


但是在vb.net上传输此文件不会提供输出。

任何想法,我将如何将此查询转换为vb.net?在此先感谢您的帮助!

最佳答案

我不知道您要做什么,但是如果您想简化它,请按以下步骤操作。您是否尝试过内部联接?就像这样。

SELECT ItemID, Item, Serial, Quantity, Size, Class, Unit, Released, Received,
Approved, Deparment from tbl_issued a INNER JOIN tbl_transaction b on
a.TransactionID = b.TransactionID Where a.TransactionID = 12458952


我假设两个表都具有基于您的查询的TransactionID。

关于mysql - 在一个Crystal报表中从多个表中获取数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34780873/

10-11 01:54