Jump to content

STRPOS As MYSQL Query?


tetuanrp

Recommended Posts

I have a site with a ton of coupons. Each coupon is a row in the database, and has a deal_description for each coupon. Currently, if I want to search all of the deals, for a number of keywords, this is how I do it:

 

Deal example (1 row of 10,000): "Basketball shoes 10 dollars off with coupon"

Keywords I want to check against: "basketball, shoes"

 

SQL QUERY ALL ROWS

FOR LOOP FOR ARRAY OF KEYWORDS ('basketball','shoes')

END LOOP

END QUERY

 

This causes a memory error with an array of over 2 items. Think the server can't handle 10,000 rows of coupons * an array w/ 5 items for example: 50,000 actions.

 

Is there any way I can do a for loop like this?:

FOR LOOP FOR ARRAY OF KEYWORDS ('basketball','shoes')

SQL QUERY AGAINST DEAL_DESCTIPION FOR KEYWORD[$i]

END QUERY

END LOOP

 

That would be much less intensive, although I don't think MYSQL has a Strpos function for me to check a string of text for a keyword.

 

Thanks in advance.

Link to comment
Share on other sites

Hmm, didn't know about that one. Not sure if that would work as I have a long description, not really comma seperated:

 

ie. Haystack is "This is my long string about colors including blue, green, red and yellow"

I wanna search this string using MYSQL for "green". Using php I'd do a strpos, but with MYSQL don't think there's a function for that.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.