MySqlTalk.com  

Go Back   MySqlTalk.com > MySQL > General
User Name
Password
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread
Old 09-21-2005, 07:42 PM   #11
radox
Junior Member
 
Join Date: Nov 2004
Posts: 13 radox is on a distinguished road
Re: Weird Join...Help Please

I have two records (rubble and johnsen).
(all garbage data now)

the first result below is correct, and the last result is correct.

id, last, first, investor1, investor2

1, Rubble, Betty, GMAC, USBank
2, Johnsen, Suzy, GMAC, USBank
1, Rubble, Betty, USBank, USBank
2, Johnsen, Suzy, USBank, GMAC
radox is offline   Fork this post Reply With Quote
Old 09-21-2005, 07:49 PM   #12
Azkaban
Senior Member
 
Join Date: Jul 2004
Posts: 167 Azkaban is on a distinguished road
Re: Weird Join...Help Please

I mean the SELECT query. What exactly is the query?
Azkaban is offline   Fork this post Reply With Quote
Old 09-21-2005, 09:16 PM   #13
radox
Junior Member
 
Join Date: Nov 2004
Posts: 13 radox is on a distinguished road
Re: Weird Join...Help Please

oops...sorry...

Code:
SELECT id1.fname AS i1,id2.fname AS i2 FROM stepcontacts AS id1,stepcontacts as id2 INNER JOIN stepclients AS sc1 ON id1.id=sc1.invesone INNER JOIN stepclients AS sc2 ON id2.id=sc2.investwo

thanks again for all your help

i took out as much as i can to simplify it.
the above just returns the investor names

Last edited by radox : 09-21-2005 at 09:18 PM.
radox is offline   Fork this post Reply With Quote
Old 09-21-2005, 09:25 PM   #14
Azkaban
Senior Member
 
Join Date: Jul 2004
Posts: 167 Azkaban is on a distinguished road
Re: Weird Join...Help Please

Not much time right now to answer you but one more question. Did you add a primary key to the second table? Meaning stepclientid
Azkaban is offline   Fork this post Reply With Quote
Old 09-21-2005, 09:27 PM   #15
radox
Junior Member
 
Join Date: Nov 2004
Posts: 13 radox is on a distinguished road
Re: Weird Join...Help Please

yes. i always have a primary key in every table simply called 'id'
radox is offline   Fork this post Reply With Quote
Old 09-21-2005, 10:12 PM   #16
radox
Junior Member
 
Join Date: Nov 2004
Posts: 13 radox is on a distinguished road
Re: Weird Join...Help Please

I finally got it. I had the clients table and contacts tables backwards.

Code:
SELECT id1.fname AS i1,id2.fname AS i2 FROM stepcontacts AS id1,stepcontacts as id2 INNER JOIN stepclients AS sc1 ON id1.id=sc1.invesone INNER JOIN stepclients AS sc2 ON id2.id=sc2.investwo

should be

Code:
SELECT sc1.fname AS i1,sc2.fname AS i2 FROM stepclients INNER JOIN stepcontacts AS sc1 ON invesone=sc1.id INNER JOIN stepcontacts AS sc2 ON investwo=sc2.id

thanks sooooo much for your help. i hope we both learned from this.
i'll never forget how to joing two foreign keys for sure...
radox is offline   Fork this post Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is the "right" join for the job? Azkaban Database Design 1 02-25-2005 02:36 PM
Cross dependency found in OUTER JOIN SQL rjmthezonenet SQL syntax 0 12-05-2004 04:41 PM
help with join shaunperry SQL syntax 0 10-07-2004 06:22 AM



All times are GMT -4. The time now is 01:29 PM.



Powered by: vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
Google
  Web http://www.mysqltalk.com
DISCLAIMERS:
1. We have no commercial interest in this site.
Banner Ads and Subscriptions will only be used to help pay for hosting and maintenance costs.
2. MySQLTalk.com is NOT affiliated with MySQL AB in any way.
3. MySQLTalk.com is NOT endorsed by MySQL AB in any way.
4. Please do not post any content that is harmful to MySQL or MySQL AB, meaning no misleading or obsolete information will be tolerated.
Well-founded constructive criticism meant to help the community is permitted.
5. This website is founded with the goal of improving the MySQL community.
We not only tolerate newbies, we encourage them.
Please do not ask newbies to "read the manual".