Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 23rd, 2005, 05:55 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL join problem

Hi,

I need to check if the same ID exists in all tables, so I am using a join, but I have 2 tables (Employment, Education) where the ID is not a primary key and the ID appears several times in these tables.

So I just need to check if the ID appears once, do you know how I can do this?

So far I have the SQL below but it doesnt work, as you can see there are 12 rows when I want to only get 2

Any help would be much appreciated.

----------------SQL--------------------

SELECT loginid, pdloginid, eloginid, EOloginid, rloginid, sloginid, edloginid
FROM login, personaldetails, employment, equalopps, referee, education, skills
WHERE (login.loginid = personaldetails.pdloginid
AND login.loginid = education.edloginid AND login.loginid = equalopps.EOloginid
AND login.loginid = referee.rloginid
AND login.loginid = employment.eloginid AND login.loginid = skills.sloginid)
----------------------------------------

RESULT
11 11 11 11 11 11 11
11 11 11 11 11 11 11
11 11 11 11 11 11 11
11 11 11 11 11 11 11
11 11 11 11 11 11 11
11 11 11 11 11 11 11
11 11 11 11 11 11 11
11 11 11 11 11 11 11
11 11 11 11 11 11 11
2 2 2 2 2 2 2
2 2 2 2 2 2 2
2 2 2 2 2 2 2


Reply With Quote
  #2 (permalink)  
Old May 23rd, 2005, 06:27 AM
Authorized User
 
Join Date: Sep 2004
Location: , , .
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Ive sorted this now using the following code:

SELECT loginid
FROM login, equalopps, skills, referee, personaldetails
WHERE loginid IN (SELECT edloginid FROM education)
AND loginid IN (SELECT eloginid FROM employment)
AND loginid = equalopps.EOloginid
AND loginid = skills.sloginid
AND loginid = referee.rloginid
AND loginid = personaldetails.pdloginid

Reply With Quote
  #3 (permalink)  
Old May 26th, 2005, 08:27 AM
Authorized User
 
Join Date: Jun 2003
Location: , , Norway.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

..or you could use a GROUP BY statement.

Gert

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL INNER JOIN problem lawsoncobol Access VBA 1 August 17th, 2006 02:29 PM
My SQL, ASP, and Inner Join Knuckles2003 Classic ASP Databases 0 October 31st, 2005 02:24 AM
SQL Join mattastic SQL Server 2000 9 April 21st, 2005 10:27 AM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM
SQL Inner Join Problem tp194 Classic ASP Databases 2 July 8th, 2003 09:59 PM



All times are GMT -4. The time now is 02:30 PM.


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