Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Need help to select all the records related to the key word.

Question posted by: indhuma (Newbie) on May 12th, 2008 10:05 AM
Hi, I want to select all the records against the key word 'thoughts' I wrote the followin code. but i'm getting error!. can you help me?
Code: ( text )
  1. $sqlquery="select * from news where match(day,category,title,article)against('thoughts  ')";
  2. $queryresult = mysql_query($sqlquery);
  3. $row=mysql_fetch_array($queryresult);
  4.  
  5. echo $row["day"]."<br>";
  6. echo $row["category"]."<br>";
  7. echo $row["title"]."<br>";
  8. echo $row["article"]."<br>";
Last edited by Atli : May 12th, 2008 at 10:42 AM. Reason: Added [code] tags.
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Atli's Avatar
Atli
Moderator
2,028 Posts
May 12th, 2008
10:46 AM
#2

Re: Need help to select all the records related to the key word.
Hi.

What error are you getting?

The MATCH AGAINST syntax is used with full-text searches. Is your table indexed for such a search?

If not, try using the WHERE LIKE syntax.. somewhat like:
Code: ( text )
  1. SELECT columns FROM myTable
  2. WHERE
  3.   column1 LIKE '%keyword%' OR
  4.   column2 LIKE '%keyword%' OR
  5.   column3 LIKE '%keyword%'
  6. /* etc... */


P.S.
I would avoid using the wildcard char (*) in the SELECT query, like you do.
It will in 99% of cases return a lot more data than needed, which causes extra overhead on the server.
Specify only the columns you need instead.

Reply
Reply
Not the answer you were looking for? Post your question . . .
178,100 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top PHP Forum Contributors