473,396 Members | 1,726 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,396 software developers and data experts.

Help with SQL query

347 100+
I have an sql qery that looks at a database to search thousands of mp3 files, it works fine, we have a table that contains the mp3 information, title etc, we also have a table that contains the words that we search that are associated to specific mp3s, i am trying to get the form that has the results of the query return all the words from the second table that relate to the mp3 being viewed

the following is what i have at the moment and a copy of the database can be found at www.colinwebdesign.co.uk/mp3 database.rar
Expand|Select|Wrap|Line Numbers
  1. SELECT [mp3].[mp3id],
  2.        [mp3].[File],
  3.        [mp3].[location],
  4.        [mp3].[Artist],
  5.        [mp3].[Information],
  6.        [mp3].[filename],
  7.        [mp3].[Information]
  8.  
  9. FROM mp3 INNER JOIN mp3voice
  10.   ON [mp3].[mp3id]=[mp3voice].[mp3id]
  11.  
  12. WHERE ([mp3voice].[Voice Type]=[Forms]![Form1]![selected_type_11]
  13.    Or  [mp3voice].[Voice Type]=[Forms]![Form1]![selected_type_2]
  14.    Or  [mp3voice].[Voice Type]=[forms]![Form1]![selected_type_3]
  15.    Or  [mp3voice].[Voice Type]=[Forms]![Form1]![selected_type_4]
  16.    Or  [mp3voice].[Voice Type]=[forms]![Form1]![selected_type_5]
  17.    Or  [mp3voice].[Voice Type]=[Forms]![Form1]![selected_type_6]
  18.    Or  [mp3voice].[Voice Type]=[forms]![Form1]![selected_type_7]
  19.    Or  [mp3voice].[Voice Type]=[Forms]![Form1]![selected_type_8]
  20.    Or  [mp3voice].[Voice Type]=[forms]![Form1]![selected_type_9]
  21.    Or  [mp3voice].[Voice Type]=[Forms]![Form1]![selected_type_10]
  22.    Or  [mp3voice].[Voice Type]=[Forms]![Form1]![selected_type_1])
  23.  
  24. GROUP BY [mp3].[mp3id],
  25.          [mp3].[File],
  26.          [mp3].[location],
  27.          [mp3].[Artist],
  28.          [mp3].[Information],
  29.          [mp3].[filename]
  30.  
  31. HAVING (Sum(1)=[Forms]![Form1]![HiddenObject]);
any help or advice would be appreciated
Aug 8 '08 #1
12 1943
NeoPa
32,556 Expert Mod 16PB
Colin, I've rearranged your SQL so that it's legible (including addition of the [ CODE ] tags and losing some extraneous parentheses - probably added by Access), but even after that I'm not clear what you're asking.

Now I can read the SQL I can see that there's really not too much wrong with it, unless you want it to do something quite different.

I could suggest a change for your WHERE clause, but only to make it a little clearer and easier to maintain. What you have now is not wrong.
Expand|Select|Wrap|Line Numbers
  1. WHERE ([mp3voice].[Voice Type] In([Forms]![Form1]![selected_type_1],
  2.                                   [Forms]![Form1]![selected_type_2],
  3.                                   [Forms]![Form1]![selected_type_3],
  4.                                   [Forms]![Form1]![selected_type_4],
  5.                                   [Forms]![Form1]![selected_type_5],
  6.                                   [Forms]![Form1]![selected_type_6],
  7.                                   [Forms]![Form1]![selected_type_7],
  8.                                   [Forms]![Form1]![selected_type_8],
  9.                                   [Forms]![Form1]![selected_type_9],
  10.                                   [Forms]![Form1]![selected_type_10],
  11.                                   [Forms]![Form1]![selected_type_11]))
What exactly were you looking for?
Aug 9 '08 #2
colinod
347 100+
I am trying to get a variable called Voice Type from the mp3voice table but only the one that relates to the currently viewed mp3 in my form that runs from the sql query

The mp3voice table has 2 fields one with the name of the file and one that contains aord associated with the file for search purposes so each file can have many words attached to it for the search, i want all of these words to appear on the form when viewing the file

i thought something like
Expand|Select|Wrap|Line Numbers
  1. SELECT [mp3].[mp3id],
  2.        [mp3].[File],
  3.        [mp3].[location],
  4.        [mp3].[Artist],
  5.        [mp3].[Information],
  6.        [mp3].[filename],
  7.        [mp3].[Information],
  8.        [mp3voice].[Voice Type]
as the select statement with the last line as the extra but this does not work

I hope this helps you understand and thanks for pointing out the simpler where statement
Aug 11 '08 #3
NeoPa
32,556 Expert Mod 16PB
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use the tags in future.

ADMIN.

PS. Having commented on this very point in my last post I admit to being more than a little surprised to see a recurrence of this so immediately.
Aug 11 '08 #4
colinod
347 100+
Sorry could not figure out how to do the code tag bit so here it is again

I am trying to get a variable called Voice Type from the mp3voice table but only the one that relates to the currently viewed mp3 in my form that runs from the sql query

The mp3voice table has 2 fields one with the name of the file and one that contains aord associated with the file for search purposes so each file can have many words attached to it for the search, i want all of these words to appear on the form when viewing the file

i thought something like

Expand|Select|Wrap|Line Numbers
  1. SELECT [mp3].[mp3id],
  2.        [mp3].[File],
  3.        [mp3].[location],
  4.        [mp3].[Artist],
  5.        [mp3].[Information],
  6.        [mp3].[filename],
  7.        [mp3].[Information],
  8.        [mp3voice].[Voice Type]
  9.  
as the select statement with the last line as the extra but this does not work

I hope this helps you understand and thanks for pointing out the simpler where statement
Aug 11 '08 #5
NeoPa
32,556 Expert Mod 16PB
Aah. You should have said before. We're more than happy to assist where needed in explaining things about the site :)

When posting a reply within a thread (a new thread has a bit more info thrown in) there is a yellow box on the right entitled REPLY GUIDELINES. This includes instructions on how to add the tags. However, that is the manual approach (in case you need to do it but you're preparing the post in a text editor or somewhere else.

When typing into the reply box you will see at the top of the box something like a toolbar. Various buttons to select which will help you to format your post. Each button has a ToolTip that explains its use if you hover the mouse pointer over it.

The one you're looking for to help with the [ CODE ] tags is the one that looks like a # character. If you have your code selected already, it will automatically enclose the tags around your selection.

Now to get on with seeing if I can't give some help for your question...
Aug 11 '08 #6
NeoPa
32,556 Expert Mod 16PB
...I am trying to get a variable called Voice Type from the mp3voice table but only the one that relates to the currently viewed mp3 in my form that runs from the sql query

The mp3voice table has 2 fields one with the name of the file and one that contains aord associated with the file for search purposes so each file can have many words attached to it for the search, i want all of these words to appear on the form when viewing the file
...
Am I right in thinking then, that there may be more than one matching [Voice Type] from your [mp3Voice] table?

Where there is one you want it shown simply, but where there is more than one, you would like the list displayed?
Aug 11 '08 #7
colinod
347 100+
Yes i think you have it each clip can have many entries into the mp3voice table but the field containing the file name will be the same for each file but each file could have many words for it

here is some data copied from the mp3voice table if that helps
Expand|Select|Wrap|Line Numbers
  1. mp3id                                                   voicetype
  2. 02 ALTMAN - HSBC BANK ( REFRESHING, NATURAL).mp3        male
  3. 02 ALTMAN - HSBC BANK ( REFRESHING, NATURAL).mp3        refreshing
  4. 02 ALTMAN - HSBC BANK ( REFRESHING, NATURAL).mp3        natural
  5. 02 ALTMAN - HSBC BANK ( REFRESHING, NATURAL).mp3        frisby
  6. 02 ALTMAN - HSBC BANK ( REFRESHING, NATURAL).mp3        relaxed
  7. 02 ALTMAN - HSBC BANK ( REFRESHING, NATURAL).mp3        calming
  8. 02 ALTMAN - HSBC BANK ( REFRESHING, NATURAL).mp3        soft sell
  9. 09 ASHBY - SILENCE OF THE LAMBS.MP3                     male
  10. 09 ASHBY - SILENCE OF THE LAMBS.MP3                     anthony hopkins
  11. 09 ASHBY - SILENCE OF THE LAMBS.MP3                     dramatic
  12. 09 ASHBY - SILENCE OF THE LAMBS.MP3                     hard hitting
  13. 09 ASHBY - SILENCE OF THE LAMBS.MP3                     movie promo
  14. 09 ASHBY - SILENCE OF THE LAMBS.MP3                     movie trailer
the bit after the mp3 filename is the word attached to the file for searching
Aug 11 '08 #8
NeoPa
32,556 Expert Mod 16PB
I was afraid that was the case. You see this is not really an process for a database. Typically DBs process records, and aggregates of groups of records, but it has no way of processing within a group within SQL.

Having said that, you are not the first to ask for something like this so I have previously found a sort of work-around for doing something very like this. It uses a call from within the SQL into a VBA function that we need to make available.

See Combining Rows-Opposite of Union.

If you have any questions, please come back here (this thread) to ask them. The other thread is not the place to ask them.
Aug 11 '08 #9
colinod
347 100+
Shouldnt the INNER join statement in my code enable me to get the details i want some how i thought that i would be able to get information from the mpvoice tabel as it is joined to the mp3 tabel when the mp3id in both
Aug 12 '08 #10
colinod
347 100+
Just to say i have made this work through a different way, i mad a new qeury that gets the information from mp3voice if the id matches the id in my form fro the mp3 file this returns all the information for each seperate clip in a form i them made the form look like it was just a list of text using the properties
Aug 12 '08 #11
NeoPa
32,556 Expert Mod 16PB
Shouldnt the INNER join statement in my code enable me to get the details i want some how i thought that i would be able to get information from the mpvoice tabel as it is joined to the mp3 tabel when the mp3id in both
Not if you're grouping, but not by that field.

A field in a GROUP BY query can either be grouped or aggregated.

If it is aggregated (as in this case) then clearly the individual elements of the group are not accessible.
Aug 12 '08 #12
NeoPa
32,556 Expert Mod 16PB
Just to say i have made this work through a different way, i mad a new qeury that gets the information from mp3voice if the id matches the id in my form fro the mp3 file this returns all the information for each seperate clip in a form i them made the form look like it was just a list of text using the properties
Thank you for letting us know you no longer need this information.

I hope your project turns out well for you :)
Aug 12 '08 #13

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

Similar topics

11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
5
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table,...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
6
by: Takeadoe | last post by:
Dear NG, Can someone assist me with writing the little code that is needed to run an update table query each time the database is opened? From what I've been able to glean from this group, the...
3
by: mcmahonb | last post by:
Hey people... I've been searching this forum for a few hours and even though this topic has been went over from many different angles; I cannot seem to figure out how to make things work on my...
4
by: n | last post by:
Hello! Here is a problem I hope you can point me to a solution. It Problem: A teacher needs to know which lesson to teach. A school has a curriculum with 26 lessons, A-Z. For a given class,...
47
by: Jo | last post by:
Hi there, I'm Jo and it's the first time I've posted here. I'm in process of creating a database at work and have come a little unstuck.....I'm a bit of a novice and wondered if anyone could...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.