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


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

Re: Linking Tables in A Particular Order

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Linking Tables in A Particular Order
Date 2012-04-20 14:35 +0200
Organization Erland Sommarskog
Message-ID <XnsA03B947C859BFYazorman@127.0.0.1> (permalink)
References <jmrhm7$k0o$1@dont-email.me>

Show all headers | View raw


David Kaye (sfdavidkaye2@yahoo.com) writes:
> Here's the original SQL:
> 
> SELECT songs.artist,songs.title FROM songs,songlookup WHERE songs.artist 
> LIKE songlookup.artist & "%"
> 
> or it could be stated as:
> 
> SELECT songs.artist,songs.title FROM songs,songlookup WHERE 
> INSTR(songs.artist,songlookup.artist)
> 

Since the syntax you use is not legal syntax in SQL Server, I conclude 
that you are using another product. I think you are better off asking 
in a forum devoted to your product, as what is a good solution in SQL
Server may not work in your environment.

I don't understand what you mean with "But the match is determined by which 
record the SQL pulls first", since in SQL Server at least, you will get 
all rows that match the conditions. But if you want rows in any certain
order, you need to use an ORDER BY clause, for instance 

   ORDER BY len(songs.artist) DESC

-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next 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