我有2张桌子 tbl_issued 和 tbl_transaction 。
tbl_issued 的列有 ItemID ,商品,序列,数量和大小。 tbl_transaction 的列已发布,已接收,已批准和部门
我的问题是我想在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的任何想法?在此先感谢您的帮助!
答案 0 :(得分:0)
我不知道你想要做什么,但如果你想简化它,请按照以下方式进行。你有没有试过内连?就是这样。
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。