tags:

views:

38

answers:

1

Hi . I'm working on a windows application project using front end "vb.net" & back end "Ms Access" I have problem in wrinting sql query Actually there are 5 tables Transaction,items,itemtitle,itemtype & userinfo. check the following query & with this referance if u get idea then plz change in correct query Thanking You

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' 
+1  A: 

It looks like you left out the ITEMS table. The below joins to that table. At any rate, it demonstrates the INNER JOIN syntax. (Usually I use aliases for readability. I purposefully them out.)

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'
Frank Shearar