Unix Technical Forum

sql select

This is a discussion on sql select within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi all, I need to do a keyword search against database table (MSSQL 2000) on particular field/column, say the ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 05:10 AM
Jemy
 
Posts: n/a
Default sql select

Hi all, I need to do a keyword search against database table (MSSQL 2000) on
particular field/column, say the keyword: "sql server 2000". The search
should return without any order restrictions, so it might return result
contain '2000' and 'sql' and 'server', or can return that contain 'server'
only. appreciate any advice.
thanks from Jemy.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 05:10 AM
David Portas
 
Posts: n/a
Default Re: sql select

SELECT ...
FROM YourTable
WHERE col LIKE '%sql%'
OR col LIKE '%server%'
OR col LIKE '%2000%'

--
David Portas
SQL Server MVP
--


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 05:10 AM
Jemy
 
Posts: n/a
Default Re: sql select

Thanks David,
Im thinking if there are any other resorts to this using regular expression
in sql select, and if possible results are returned in order of preference
(from mostly match).
Im not sure why I want to use other resort, but it seems using mix 'or' and
'and' doesnt return closest match result.


"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:MqSdnV7CXvv4x6DcRVn-hA@giganews.com...
> SELECT ...
> FROM YourTable
> WHERE col LIKE '%sql%'
> OR col LIKE '%server%'
> OR col LIKE '%2000%'
>
> --
> David Portas
> SQL Server MVP
> --
>
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 05:11 AM
Erland Sommarskog
 
Posts: n/a
Default Re: sql select

Jemy (cutejemy@REMOVEhotmail.com) writes:
> Im thinking if there are any other resorts to this using regular
> expression in sql select, and if possible results are returned in order
> of preference (from mostly match). Im not sure why I want to use other
> resort, but it seems using mix 'or' and 'and' doesnt return closest
> match result.


There are no regular expressions in SQL like in, say, Perl, so David's
suggestion is about the best you can get, unless you want to explore
full-text indexing.




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

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:11 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com