All,
I need a little help understanding which concepts / functions /
methods / strategies I should use to accomplish what I'll describe
below. Note - the real implementation isn't about music - I just
thought it would be easier to understand, if not more fun to think
about.
I have a table with 8,000 rows. Let's call that the "TBL_Fav_So ngs"
table. It contains a list of my favorite songs, in the column |
MyFavs|.
I have a table with 117,000 rows. Let's call that the
"TBL_All_Albums " table. It contains a list of albums in my music
library. The table has three columns - |Album|Songs|Fa vSongs|
|Album| contains the Album name.
|Songs| contains the songs on an album, in a text field - all songs
listed together in one field.
|FavSongs is empty at the moment.
I want to wind up with a table in which FavSongs is populated with the
names of songs that are my favorites, for each album listed.
I need to search the |Songs| field of the "Albums" table, for matches
from the songs listed in the |MyFavs| column in the "TBL_Fav_So ngs"
table.
Wherever I find a match, I want to populate the |FavSongs| field.
There can be multiple matches per album, and a song can be on multiple
albums ($%^& annviersary reissues!).
I think I'm going to need to use nested loops, and have a routine that
fills in the |FavSongs| field, appending new values to the field as it
finds matches. I guess I don't know whether to search one row in the
"TBL_All_Albums " table for matches to every row in the "TBL_Fav_So ngs"
table, or to search all of the rows in the "TBL_All_Albums " table for
matches to one row in the "TBL_Fav_So ngs" table.
Suggestions, including a good resource for learning how to do this?
Thanks,
Patrick 5 1284
Hi Patrick,
On Jul 21, 10:29 pm, Patrick A <park...@stradl ey.comwrote:
I have a table with 8,000 rows. Let's call that the "TBL_Fav_So ngs"
table. It contains a list of my favorite songs, in the column |
MyFavs|.
I have a table with 117,000 rows. Let's call that the
"TBL_All_Albums " table. It contains a list of albums in my music
library. The table has three columns - |Album|Songs|Fa vSongs|
|Album| contains the Album name.
|Songs| contains the songs on an album, in a text field - all songs
listed together in one field.
|FavSongs is empty at the moment.
I want to wind up with a table in which FavSongs is populated with the
names of songs that are my favorites, for each album listed.
I would copy TBL_All_Albums into a table with a different structure
such as
TBL_All_Albums_ Revised with three columns - |Album|Song|IsF av|
Then I could set the IsFav flag by running a simple SQL query such as
UPDATE TBL_All_Albums_ Revised
SET IsFav = TRUE
WHERE Song = ANY(
SELECT MyFavs
FROM TBL_Fav_Songs);
For a database to work well, each entry in column Song should contain,
not a list of songs, but a single song.
Hope that helps,
Chris
Try something like the following query which would update TBL_All_Albums
by setting the FavSongs column equal to the FavSongs column in
TBL_Fav_Songs. So for every row that contains a song in the Song column
which matches a FavSong, the first FavSong column would get the matching
FavSong from the 2nd table.
UPDATE TBL_All_Albums t1 INNER JOIN TBL_Fav_Songs t2 ON t1.Song =
t2.FavSong SET t1.FavSong = t2.FavSong
Rich
*** Sent via Developersdex http://www.developersdex.com ***
Hi Rich,
So for every row that contains a song in the Song column
which matches a FavSong, the first FavSong column would get the matching
FavSong from the 2nd table.
UPDATE TBL_All_Albums t1 INNER JOIN TBL_Fav_Songs t2 ON t1.Song =
t2.FavSong SET t1.FavSong = t2.FavSong
Your SQL is fine but Patrick A writes:
"|Songs| contains the songs on an album, in a text field - all songs
listed together in one field."
so the SQL will result in zero updates.
Once he gets the structure right, your SQL will do the heavy lifting
for him.
Just my thoughts,
Chris
Rich, Chris,
Thanks for trying to help.
Two issues:
1. I cannot change the structure of the database.
2. Knowing if an album has a favorite is not sufficient. The result I
need is to have the favorite (or favorites - there can be multiples)
written to the |FavSongs| field in the TBL_All_Albums.
I'll keep digging...
Patrick
On Jul 22, 2:37 pm, Patrick A <park...@stradl ey.comwrote:
Two issues:
1. I cannot change the structure of the database.
2. Knowing if an album has a favorite is not sufficient. The result I
need is to have the favorite (or favorites - there can be multiples)
written to the |FavSongs| field in the TBL_All_Albums.
In that case, you will need to use some VBA code and, as you
predicted, nested loops. I'm sure we can help with that.
I would scan the larger table and compare each song with the list of
favourites. How are you separating each of the songs in the Songs
field?
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gleep |
last post by:
Hey Guys,
I've got a table called Outcomes. With 3 columns and 15 rows
1st col 2nd col 3rdcol
outcome date price
There are 15 rows for each record, each row accounts for a different type of outcome
I'm having trouble with MySQL date comparison. I'm looking for some kind of query that will compare
the all date column and only give me the latest date. Then once I have it, ...
|
by: Megan |
last post by:
Hi everybody-
I'm helping a friend with a music database. She has an old one and is
creating a new one. She wants to compare records and fields in the old
database with records and fields in the new database. For instance,
her old database has a table with Band Info in it. Her new database
also has a table with Band Info in it but slightly different. I was
wondering if there was an easy way to compare the fields from similar
tables in...
|
by: geronimo_me |
last post by:
Hi,
I am atempting to compare part of a field with the whole of another
field in access. Is this possible?
Basically I have 2 tables with the following info:
Table1
Field1 = MR.
|
by: VMI |
last post by:
I have two tables and I want to compare these two tables with a query( ie.
"select * from A where B.key = A.key") and the result will be stored in a
3rd table (table C). is this possible? If necessary, I can create the schema
for the 3rd table (C) since it'll be exactly like table A. But I'm more
interested in being able to store the resulting set into another table.
Thanks.
|
by: rcolby |
last post by:
Evening,
Wondering if someone can point me in the right direction, on how I would
compare a system.guid with a system.byte.
system.guid (pulled from sql server table with a data type of
uniqueidentifier, originally taken from objectGUID from active directory
domain)
| |
by: Justin Emlay |
last post by:
I have two lists. These can be in either table form or array. That is, my
data is in a dataset which I can move to an array if need be. ListA is a
master list and it contains all items. ListB contains the same items but
not necessarily all the items. I need to know which items are missing.
I remember messing with a compare array function but now I can't seem to
find it anywhere. Ideas? I would rather NOT loop through each item in...
|
by: adeelanjum2001 |
last post by:
I have two datatables with same structure. i want to compare the values
in each row. for example: datatable1.rows(0).item(0) =
datatable2.rows(0).item(0)
one way to compare the rows in datatable is to check them in loop and
doing element by element. is there any other way
thanks in advance for any help
|
by: Shelley |
last post by:
Compare Current Year Worksheet with Previous Year Worksheet and if SSN exists in Current Year Worksheet & Not in Previous Year - Copy this Row from Current Year Worksheet & Paste into Previous Year Worksheet
Compare Previous Year Worksheet with Current Year Worksheet and if SSN exists in Previous Year Worksheet & Not in Current Year Worksheet - Delete this Row out of Previous Year Worksheet - THIS IS WHERE I'M HAVING TROUBLE.
This is the...
|
by: inpuarg |
last post by:
I have 2 datatables. They are identical. I want to compare them by
cell's content. They are all same.
But dt1 == dt2 or
dt1.GetHashCode() == dt2.GetHashCode() doesn 't work.
There are big amount of rows in theese datatables . So i don 't want
to enumerate each rows. This is not efficient and unacceptable for my
current application.
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |