Forum Moderators: open

Message Too Old, No Replies

ASP keyword search.

         

em00guy

7:37 pm on Jan 28, 2002 (gmt 0)



How do I construct a SQL statement that will search db fields for certain words that are contained in that field.

bmcgee

1:47 am on Jan 29, 2002 (gmt 0)

10+ Year Member



sSql = "SELECT * FROM mytable WHERE field1 LIKE '%cat%' AND field2 LIKE 'bird%'

%cat% will find: "cat", blackcat", "catbird", and "scathing" (i.e. anything with "cat" in it)

bird% will find: "bird", "birdie", but NOT "catbird" (i.e. anything starting with "cat")

Just a warning, using the LIKE statement will hurt your database performance, as it causes a full scan and cannot use the indexes on your fields.

em00guy

2:41 am on Feb 6, 2002 (gmt 0)



sorry for the delayed gratitude but thanx.