Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1002

Re: Linking Tables in A Particular Order

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From "Bob Barrows" <reb01501@NOSPAMyahoo.com>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Linking Tables in A Particular Order
Date Fri, 20 Apr 2012 10:21:19 -0400
Organization A noiseless patient Spider
Lines 42
Message-ID <jmrrbv$cso$1@dont-email.me> (permalink)
References <jmrhm7$k0o$1@dont-email.me>
Injection-Date Fri, 20 Apr 2012 14:20:47 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="vQmQhKLKuh0OvmkK+suVIw"; logging-data="13208"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/1ciwrWUVoigA9pepgj0lDcBTiHNF8WIM="
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.6157
X-RFC2646 Format=Flowed; Response
X-Antivirus-Status Clean
X-Newsreader Microsoft Outlook Express 6.00.2900.5931
X-Antivirus avast! (VPS 120302-0, 03/02/2012), Outbound message
Cancel-Lock sha1:oIFrobcn185zLn4tEJk9jYM8hvk=
X-Priority 3
X-MSMail-Priority Normal
Xref csiph.com comp.databases.ms-sqlserver:1002

Show key headers only | View raw


David Kaye wrote:
> What I need to do is create a SQL that joins content from one table to
> another but in a certain order.  I have a table of songs which
> includes both the artist and title in the title field,

My first priority would be to fix this horrendous design error before 
continuing to do anything else. Assuming you are dealing with data imported 
from an external source, you need to generate separate columns for artist 
and song title after importing the data. Details depend on how the data in 
that "title" column is delimited

> and a table of
> songlookups which includes only the artist in the artist field.  What
> I want to do is find out which songs are by artists that match
> artists already in the songlookup table.

A task that would be supremely easy if you implemented my suggestion, 
wouldn't it?

>
> But the problem is that I need to link the songlookup table in a
> specific order, namely reverse order by length of artist field.  That
> way I can try finding a match with the band "Guess Who" before
> finding a match with the "Who".  Otherwise, it's more likely I'll
> match the song with the wrong band.
<snip>
>
> SELECT songs.artist,songs.title FROM songs,songlookup WHERE
> INSTR(songs.artist,songlookup.artist)

INSTR? Is this Access or SQL Server? Perhaps Access with a SQL Server 
backend?
>
> But the match is determined by which record the SQL pulls first, and
> it appears to relate to which data just happens to be accessed first.
> I want it to be able to pull the longest songlookup.artist first.
>
> Ideas anyone?

Fix the real problem and the solution will be a simple outer join. 

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

Linking Tables in A Particular Order "David Kaye" <sfdavidkaye2@yahoo.com> - 2012-04-20 04:36 -0700
  Re: Linking Tables in A Particular Order Erland Sommarskog <esquel@sommarskog.se> - 2012-04-20 14:35 +0200
  Re: Linking Tables in A Particular Order "Bob Barrows" <reb01501@NOSPAMyahoo.com> - 2012-04-20 10:21 -0400

csiph-web