Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    5

    Unanswered: Searching unreleated tables

    I have three tables with name and keyword fields - tblRefJournals, tblRefBOoks and tblRefInternet. These tables are not related but they are viewable from the same form/subform by clicking the proper radio button.

    I would like to create a subset which would contain all the records that contain (SQL LIKE) keywords that a user enters into a textbox.

    I can set a filter for the records which will reflect the results of the SQL SELECT statement but I can't figure out how exactly to do the SQL statement. I've never tried to create an SQL for data from unrelated tables before.

    Any help appreciated.

    Penn

    P.S. I'm working in MS Access 2003 (*.mdb) but I don't think that should make any difference.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select 'journal  ' as source
         , name
      from tblRefJournals
     where keyword like '%foo%'
    union all
    select 'book     ' as source
         , name
      from tblRefBOoks
     where keyword like '%foo%'
    union all
    select 'internet ' as source
         , name
      from tblRefInternet
     where keyword like '%foo%'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Oct 2004
    Posts
    5
    Thank you very much. I'll have a good look at 'union all'.

    Penn

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •