Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-14-2012, 12:05 PM   PM User | #1
Oatley
New Coder

 
Join Date: Sep 2012
Posts: 70
Thanks: 56
Thanked 0 Times in 0 Posts
Oatley is an unknown quantity at this point
Join where there is sometimes no value?

Hello, I am after some help please. I have two tables, which I wish to query to output all the records in table_a.

- In table_a I have a field named 'thecategoryid'
- In table_b I have a field named 'categoryid'

But my problem is in table_a 'thecategoryid' field in each row can sometimes contain a value and sometimes not, so I can't join like so

table_a.thecategoryid = table_b.catgoryid

So how can I output all records in table_a with a join on table_b but with it not mattering if there is or there is not a value on the row 'thecategoryid'

Is this possible?

Thank you

Last edited by Oatley; 12-14-2012 at 02:34 PM..
Oatley is offline   Reply With Quote
Old 12-14-2012, 01:56 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Sure you can. Just use a LEFT JOIN to fetch all records from the primary table (governed by the where clause of course), and any matching records from the child table.
Fou-Lu is offline   Reply With Quote
Users who have thanked Fou-Lu for this post:
Oatley (12-14-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 09:51 PM.


Advertisement
Log in to turn off these ads.