home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,598 of 19,505   
   Erland Sommarskog to David Kaye   
   Re: Linking Tables in A Particular Order   
   20 Apr 12 14:35:48   
   
   From: esquel@sommarskog.se   
      
   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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca