473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Creating a Query

I am developing a database of songs. I have given each song a Theme as I want to be able to search through the database and find all songs that match Theme 1. I would then like to be able to add a second Theme to each song and then search for all songs that meet the first criteria or the second. For example,

Table 1:
Holiness
Grace and Mercy
Peace (etc)

Table 2 is the same, so that song 1 could be about Holiness and Grace (in Table 1) and Mercy (in Table 2).

I have created these tables and a basic Query, but this only allows me to search for records from 1 table. In SQL View it is:

Expand|Select|Wrap|Line Numbers
  1.  SELECT tblSongTheme.Theme, tblSongs.[First Line]
  2. FROM tblSongTheme INNER JOIN tblSongs ON tblSongTheme.ID = tblSongs.Theme
  3. WHERE (((tblSongTheme.Theme)="holiness"));
I hope you follow what I am trying to say.
Oct 24 '06 #1
1 1246
MMcCarthy
14,534 Expert Mod 8TB
Set up tables as follows:

tblSongs (List of Songs)

SongsID
SongName
FirstLine
Artist

tblThemes (List of Available Themes)

ThemeID
Theme

tblSongThemes (list of Songs and Themes by ID)

SongsID
ThemeID


Now create a form with tblSongs as its record source.
Create a Subform with the following query as its record source.
Use SongID for the parent child relationship.

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT tblSongThemes.SongsID, tblThemes.ThemeID, tblThemes.Theme FROM tblSongThemes INNER JOIN tblThemes
  3. ON tblSongThemes.ThemeID=tblThemes.ThemeID
  4.  
  5.  
You can now create your query to search for songs as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT tblSongs.SongsID, tblSongs.SongName, tblSongs.FirstLine, tblSongs.Artist
  3. FROM tblSongs INNER JOIN (tblSongThemes INNER JOIN tblThemes
  4. ON tblSongThemes.ThemeID=tblThemes.ThemeID) 
  5. ON tblSongs.SongsID=tblSongThemes.SongsID
  6. WHERE (tblSongThemes.Theme IN ('Holiness', 'Grace and Mercy');
  7.  
  8.  
Oct 24 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: randi_clausen | last post by:
Using SQL against a DB2 table the 'with' key word is used to dynamically create a temporary table with an SQL statement that is retained for the duration of that SQL statement. What is the...
4
by: Jeremy Weiss | last post by:
Thanks to much help from everyone in my previous thread, I've made it a pretty fair ways into my billing/invoicing db. I'm now needing a way to cycle through all the records in a table and create...
1
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
8
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1;...
2
by: deja | last post by:
Hello, I am creating an a to z list - basically a count of all results that start with the letter "A", "B", "C" .... and so on. I am pretty poor at SQL so I am sure some brains out there can...
5
by: darnnews | last post by:
Hi, I have been creating a database to keep track of press clippings, but I have hit a couple stumbling blocks. Any help is much appreciate. 1) Seeing if my query is done I have the...
4
by: DeanL | last post by:
Hi Guys, I need some help creating a query that is going to take between 1 and 10 parameters. The parameters are entered on a form into text boxes that may have data or be empty. Is there a...
17
Motoma
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction:...
3
LMHelper
by: LMHelper | last post by:
How do I create a table from a query that will UPDATE each time I update the original table? I created a table from a query and it stayed the same for the past couple of months and did not...
2
by: Andy | last post by:
Hi guys I having a problem creating a report in Access 2003 project talking to a SQL database through and ODBC connect. After hours of trying things from Access Help, MSDN and Google I still...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.