Forums

This topic is locked

doesnt like =

Posted 23 Oct 2001 18:18:17
1
has voted
23 Oct 2001 18:18:17 Leon Radley posted:
I have this query

SELECT make, freesearch
FROM mc
WHERE make = 'varMake' AND freesearch LIKE '%varFreeSearch"'


and the variables

varMake % Request("make"
varFreeSearch % Request("freesearch"

and the make is a dropdown list with numbers as different makes ex. 6 is suzuki

but i don't get a single record if i test the query even when i remove the freesearch

if I remove the varible and just put make = 6 then it works why doesnt it work with the varible? seems like the % doesnt work??

im using
WinXP pro ISS 5.1
Ultradev 4.01
and Mysql 4
the make column is of "int" type and the freesearch is a "varchar".

Cheers

// Leon

Replies

Replied 23 Oct 2001 22:11:03
23 Oct 2001 22:11:03 Owen Eastwick replied:
Your problem is that you have put your number variable, varMake, in quotes so SQL treats it as a text string.

Here are some pointers:

To look for a numeric match: WHERE DbFieldName = varMyNumber
To look for an exact text match: WHERE DbFieldName LIKE 'varMyText'
To look for a text match within text (using % wildcards): WHERE DbFieldName LIKE '%varMyText%'

So change your SQL statement as follows:

SELECT make, freesearch
FROM mc
WHERE make = varMake AND freesearch LIKE '%varFreeSearch%'

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Reply to this topic