Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
LEFT INNER RIGHT Joins not problem
Old 04-27-2010, 01:53 PM LEFT INNER RIGHT Joins not problem
Extreme Talker

Posts: 173
Trades: 0
I am trying to display all project from tbl1 regardless if there is no record in tbl2.

I have been reading about the different types of JOINS

INNER - corisponding record in both tables
Left-record only needs to exist it tbl1
right-record only needs to exist in tbl2
outer-will display all records from either tbl1 or tbl2 regardless if there is a corrisponding record in the other table.

If I have this right, then why would I not is the follow statement not working?

Quote:
SELECT * FROM tbl_project LEFT JOIN tbl_project_details ON tbl_project.project_id = tbl_project_details.project_id
The result I am getting is that it only displays the record if there is a record set in table 2.

If we start with baby steps, have i understood the joins properly?
dgkindy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-27-2010, 03:28 PM Re: LEFT INNER RIGHT Joins not problem
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Drop the "LEFT" and just use a "JOIN"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-27-2010, 05:44 PM Re: LEFT INNER RIGHT Joins not problem
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Many coworkers tend to find this visual explanation of the joins useful:
http://www.codeproject.com/KB/databa...JOINS_orig.jpg


Just to extends a bit further what you told us:
INNER JOIN: returns rows that are matched in both tables
OUTER JOIN: returns rows that are matched in 1 or both table. The LEFT or RIGHT keywords refer to the A and B in the schema above.
an LEFT OUTER JOIN means that every rows from table A will be returned, with records from table B if some match. But records from table B might not be returned, where all records from table A will be.

And to follow the pic above, an LEFT/RIGHT JOIN and an LEFT/RIGHT OUTER JOIN are the same.
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 04-27-2010 at 05:46 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to LEFT INNER RIGHT Joins not problem
 

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21507 seconds with 12 queries