Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 08-07-2003, 03:42 AM   #1
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
CONTAINS statement in SQL

i am using ASP and an access database, and i'm trying to do a search facility using the CONTAINS statement, but i keep getting this error.-

Microsoft JET Database Engine error '80040e14'
Syntax error (missing operator) in query expression 'CONTAINS(cusemail, 'chris', 1) > 0'.


the whole statement in sql is.-

set objRSManu = server.CreateObject("ADODB.Recordset")
sql = "SELECT score(1), orderdate, cusemail from Orders WHERE CONTAINS(cusemail, 'chris', 1) > 0"
objRSManu.open sql , Conn

this search should return all the records that have "chris" in the email address, what am i doing wrong!!
chris1977uk is offline   Reply With Quote
Old 08-07-2003, 03:50 AM   #2
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
been told this should work too.-

SELECT id FROM orders WHERE CONTAINS (cusemail, 'chris') > 0

but it doesn't

please help
chris1977uk is offline   Reply With Quote
Old 08-07-2003, 08:08 AM   #3
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
CONTAINS can't be used in Access databases. It can only be used with SQL Server. The version of SQL that Access uses does not have that functionality; at least my version of Access 2000 doesn't.
doctorgonzo is offline   Reply With Quote
Old 08-07-2003, 08:36 AM   #4
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
cheers doctor, i think you are right!

i have however tried it with SQL Server as well, though i didnt get an error message after making the table full-text indexed, it doesnt return any records either..

any ideas anyone?
chris1977uk is offline   Reply With Quote
Old 08-07-2003, 08:49 AM   #5
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
What is the ">0" doing there? Have you tried using it without the >0?
doctorgonzo is offline   Reply With Quote
Old 08-07-2003, 08:52 AM   #6
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
yeah i did try it without it

its something to do with scores, and how the contains operator grades its matches, if theres a match it gives it an index greater than 0, the example i "borrowed" the statement from had that clause in.
chris1977uk is offline   Reply With Quote
Old 08-07-2003, 09:23 AM   #7
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
Hmm, the T-SQL reference I have for SQL Server doesn't say much about weighting.

Excactly what records are you trying to return? Have you tried using a wildcard? For example, if you want to return all records where cusemail starts with "chris", use "SELECT id FROM orders WHERE CONTAINS (cusemail, 'chris*')

If all else fails, could LIKE work? For example, "SELECT id FROM orders WHERE cusemail LIKE 'chris*'" I usually use LIKE in queries.
doctorgonzo is offline   Reply With Quote
Old 08-07-2003, 09:27 AM   #8
Member (7 bit)
 
chris1977uk's Avatar
 
Join Date: Sep 2002
Location: Middlesbrough, UK
Posts: 108
not tried it with * yet, but i will do

got some like statements that work, and they work in Access too !!
chris1977uk is offline   Reply With Quote
Old 08-07-2003, 09:39 AM   #9
Professional gadfly
 
doctorgonzo's Avatar
 
Join Date: Jan 2002
Location: Minneapolis, MN
Posts: 6,364
Send a message via MSN to doctorgonzo
Yes, LIKE works with Acess SQL, which is why I tend to use them more (I started with Access and then moved to SQL Server).
doctorgonzo is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:04 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2