Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MYSQL 'CONTAINS' funtion????

Status
Not open for further replies.

digger69

Technical User
Jan 13, 2003
8
0
0
AU
SELECT *
FROM tbl_stk, tbl_deal
WHERE tbl_stk.stk_des LIKE '%varsearchtxt%' AND tbl_stk.stk_loc LIKE
'%varsearchdrop%' AND tbl_stk.stk_range LIKE '%varsearchprice%' AND
tbl_stk.deal_dl = tbl_deal.deal_dl

Hi, hopefully I have a minor problem that wont tax anybody too much :)

In the above query the "LIKE" function is to literal. I need an equivilent
that is more flexable.
For example, in the 'tbl_stk.stk_des" I may have ' 1999 Holden Commodore',
using the like function and entering 1999 Holden Commodore in my search text
box works fine.

However, if I enter 1999 Commodore or 99 comm ect the search returns 0
results...

I would have thought the function to use to achieve my objective would be
'CONTAINS' instead of 'LIKE' but MYSQL does not recognise the 'CONTAINS'
function.....

Clear as mud??........Any ideas??

Thanx in advance..... AL

 
you need to use the function regexp something like this

ucase("1999 Holden Big block Commodore") regexp "99.*COMM"


if you have not used regular expressions before they take a bit of getting started on but well worth persevering

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top