我正在使用前端“vb.net”&amp ;;正在开发一个Windows应用程序项目。后端“Ms Access”我在写错sql查询时遇到问题 实际上有5个表Transaction,items,itemtitle,itemtype&用户信息。 检查以下查询&如果你有想法,那么这个referance然后plz改变正确的查询 感谢你
SELECT
TRANSACTIONS.ACCESSIONNO AS
ACCESSIONNO,TRANSACTIONS.TYPEID,
TRANSACTIONS.CHECKOUTDATE AS CHECKOUTDATE,ITEMTITLE.ITEMTITLE,
TRANSACTIONS.CHECKEDOUTBY,
USERINFO.FULLNAME_ENG,
USERINFO.FULLNAME_MAR,
TRANSACTIONS.ACCOUNTNO,
ITEMTYPE.TYPES_MAR,
ITEMTYPE.TYPES_ENG
FROM
TRANSACTIONS,ITEMTYPE,
ITEMTITLE,
USERINFO
WHERE
TRANSACTIONS.ACCOUNTNO=USERINFO.ACCOUNTNO
AND TRANSACTIONS.ACCESSIONNO=ITEMS.ACCESSIONNO
AND ITEMS.ITEMTITLEID=ITEMTITLE.ITEMTITLEID
AND TRANSACTIONS.TYPEID=ITEMTYPE.TYPEID
AND TRANSACTIONS.STATUS='Enabled'
答案 0 :(得分:1)
看起来你遗漏了ITEMS表。下面加入到该表中。无论如何,它演示了INNER JOIN语法。 (通常我会使用别名来提高可读性。我故意将它们用掉。)
SELECT TRANSACTIONS.ACCESSIONNO AS ACCESSIONNO, TRANSACTIONS.TYPEID, TRANSACTIONS.CHECKOUTDATE AS CHECKOUTDATE, ITEMTITLE.ITEMTITLE, TRANSACTIONS.CHECKEDOUTBY, USERINFO.FULLNAME_ENG, USERINFO.FULLNAME_MAR, TRANSACTIONS.ACCOUNTNO, ITEMTYPE.TYPES_MAR, ITEMTYPE.TYPES_ENG
FROM TRANSACTIONS
INNER JOIN ITEMTYPE ON (TRANSACTIONS.TYPEID = ITEMTYPE.TYPEID)
INNER JOIN ITEMTITLE ON (ITEMS.ITEMTITLEID = ITEMTITLE.ITEMTITLEID)
INNER JOIN USERINFO ON (TRANSACTIONS.ACCOUNTNO = USERINFO.ACCOUNTNO)
INNER JOIN ITEMS ON (TRANSACTIONS.ACCESSIONNO = ITEMS.ACCESSIONNO)
WHERE TRANSACTIONS.STATUS = 'Enabled'