Jump to content

MySQL - Searching


ryanschefke

Recommended Posts

Hello,

 

I already have the following query working successfully. I am looking to add a search capability to only pull the rows where the string in the "state" column of my database is part of a large amount of text. In other words, Users will specify that they only want to see rows where the state column is Michigan, Ohio, Texas, California, Florida, etc... My two questions are:

 

1) How should I be storing the text in MySQL for the states they want to see? Separated by commas (Michigan, Texas, Ohio...) or just bunched together with no spaces (MichiganTexasOhio...) or a different way? I could store it in any way. Is there a certain format I should store it in, Text, Blob, etc to make it searchable?

 

2) What would I need to add to the query below to make this search and do it fast? Basically, a search with this logic "only pull the rows where the value in the state column is included in a paragraph of text"

 

$query = "SELECT v.organization, v.city, v.region, v.country, DATE_FORMAT(v.dateTime, '%m/%d/%Y %l:%i %p'), v.visitorID, v.searchWords,
COUNT(h.hitID) as sumHits FROM visitors as v, hits as h WHERE v.customerID='$customerID_ck' AND cast(v.dateTime as date)='$sGMTMySqlDate' 
AND h.visitorID=v.visitorID GROUP BY h.visitorID ORDER BY $sort LIMIT $start, $displayToday";

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.