Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 26th, 2004, 01:35 AM
Authorized User
Join Date: Nov 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to vanjamier Send a message via AIM to vanjamier Send a message via MSN to vanjamier Send a message via Yahoo to vanjamier
Default Join table puzzle...

Hi there, i need help with sql

I have 4 tables,

UserTab(Id, Name, Email, Phone)
ItemTab(ItemId, Type, Item)
relationTab(Id, TransactionId, ItemId, Quantity, ReturnedDate, ReceiverId)
loanTab(Id, TransId, BorrowerId, DateBorrowed, IssuerId, ReceiverId)

I wanna do a search for employee and return the items tht the employee borrowed.

Whats wrong with my sql statement ?

SELECT UserTab.Name, ItemTab.Item
FROM LoanTab INNER JOIN UserTab ON LoanTab.ReceiverId = UserTab.Id
INNER JOIN relationTab ON LoanTab.TransId = relationTab.TransactionId
INNER JOIN ItemTab ON relationTab.ItemId = ItemTab.ItemId
WHERE Name LIKE '%strName%'

I tried doing this in the query analyzer it displayed the fields but no entries..

Pls help, thanks in advance
Education ruined me
Old November 26th, 2004, 04:43 AM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

Your joins and table structures look a bit strange.
Why are Trans(action)Id and ReceiverId in both loanTab and relationTab?
Why do you need loanTab in your query, why not just UserTab joined to relationTab on UserId = ReceiverId joined to ItemTab on ItemId = ItemId?


Joe (Microsoft MVP - XML)

Similar Threads
Thread Thread Starter Forum Replies Last Post
table join debbiecoates SQL Server 2000 2 July 2nd, 2008 01:39 PM
can i make self join table seco MySQL 1 April 18th, 2007 11:17 PM
While join a new table, other fields are vanished ksskumar2000 Crystal Reports 0 March 14th, 2005 06:35 AM
could i join function(return table) with a table alyeng2000 SQL Server 2000 6 September 30th, 2004 07:23 AM
outer join on same table roog SQL Language 4 September 30th, 2004 05:31 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.