If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Searching unreleated tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-19-05, 18:09
pennwhite pennwhite is offline
Registered User
 
Join Date: Oct 2004
Posts: 5
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.
Reply With Quote
  #2 (permalink)  
Old 02-20-05, 00:02
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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%'
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-20-05, 07:43
pennwhite pennwhite is offline
Registered User
 
Join Date: Oct 2004
Posts: 5
Thank you very much. I'll have a good look at 'union all'.

Penn
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On