Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - SQL/Access Search for ’Pairs’ of records
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SQL/Access Search for ’Pairs’ of records

 Post Reply Post Reply Page  <12
Author
schammy View Drop Down
Newbie
Newbie


Joined: 30 July 2003
Location: Israel
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote schammy Quote  Post ReplyReply Direct Link To This Post Posted: 31 July 2003 at 12:21am

Thanks Michael,

That sounds more like it. I knew it would probably be a simple answer. One last bit of advice though (I am a doctor and not a proficient programmer!)...

What would the query string be for 2 fields ('no.' and 'year')?

 

 

Back to Top
Morgan View Drop Down
Groupie
Groupie


Joined: 13 September 2002
Location: United States
Status: Offline
Points: 114
Post Options Post Options   Thanks (0) Thanks(0)   Quote Morgan Quote  Post ReplyReply Direct Link To This Post Posted: 02 August 2003 at 10:00pm

How about changing the way you are displaying the data?  What about: 

Surname (of search), Firstname (of search), Year, No, Surname (of spouse), Firstname (of spouse)

To do this in MS Access, then for your SQL query try:

SELECT h.surname, h.first_name, h.[year], h.[no.], w.surname, w.first_name
FROM marriages h
INNER JOIN marriages w
ON h.[year] = w.[year]
AND h.[no.] = w.[no.]
AND h.surname <> w.surname
AND h.first_name <> w.first_name
WHERE h.surname LIKE '*JONES*';

In MS SQL Server:

SELECT h.surname, h.first_name, h.[year], h.[no.], w.surname, w.first_name
FROM marriages h
INNER JOIN marriages w
ON h.[year] = w.[year]
AND h.[no.] = w.[no.]
AND h.surname <> w.surname
AND h.first_name <> w.first_name
WHERE h.surname LIKE '%JONES%';

Morgan
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.