2 Replies - 656 Views - Last Post: 25 August 2011 - 05:27 AM Rate Topic: -----

#1 osama_  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-October 09

Joining two tables with displaying all rows of one of them ?

Posted 24 August 2011 - 08:29 AM

In Microsoft Access, I have two tables:
Example:
Devices:
Dev_id Dev_name
1 Dev1
2 Dev2
3 Dev3
and
Faults:
Fault_id Dev_id Date
1 1 3/5/2011
2 1 4/5/2011

I need a query that displays ALL devices and ,if exists, the corresponding faults, like that:
Dev_id Dev_name Date
1 Dev1 3/5/2011
1 Dev1 4/5/2011
2 Dev2 (Null or anything)
3 Dev3 (Null or anything)

can this be done :/ ?

Is This A Good Question/Topic? 0
  • +

Replies To: Joining two tables with displaying all rows of one of them ?

#2 Jstall  Icon User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: Joining two tables with displaying all rows of one of them ?

Posted 24 August 2011 - 02:09 PM

Hi,

You could do this using a left join. Something like:
SELECT d.*,f.date
FROM Devices d
LEFT JOIN Faults f ON f.Dev_id = d.Dev_id


Would do the trick.

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#3 osama_  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-October 09

Re: Joining two tables with displaying all rows of one of them ?

Posted 25 August 2011 - 05:27 AM

Thanks a lot, it worked greatly :flowers:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1