SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MYSQL - Full-Text Searches with more words

    Hi,
    I've to set up a search for a simple
    question answer site the user fill in
    the question click on a next button
    and he/she must see if there is
    similar question so I ended up doing like
    (the user's input YourSQL Tricks)
    PHP Code:
    CREATE TABLE IF NOT EXISTS cc_question (
        
    id INT UNSIGNED NOT NULL AUTO_INCREMENT,
        
    uid_questioner bigint(20unsigned NOT NULL,
        
    id_answerer INT UNSIGNED DEFAULT NULL,
        
    title varchar(255NOT NULL,
        
    notes TEXT DEFAULT NULL,
        
    reply TEXT DEFAULT NULL,
        
    status tinyint(1NOT NULL default 0 COMMENT '0 the question has not been answered,1 the question has been answered',
        
    in_home tinyint(1NOT NULL default 0 COMMENT '0 no,1 yes ',
        
    PRIMARY KEY  (id),
        
    FULLTEXT (title)
    ENGINE=MyISAM  DEFAULT CHARSET=utf8;
    INSERT INTO cc_question (id,uid_questioner,title,) VALUES
         
    (null,34,'MySQL Tutorial'),
         (
    null,45,'How To Use MySQL Well'),
         (
    null,36,'Optimizing MySQL'),
         (
    null,29,'1001 MySQL Tricks'),
         (
    null,12,'MySQL vs. YourSQL'),
         (
    null,31,'MySQL Security');
    SELECT FROM cc_question WHERE MATCH (titleAGAINST ('YourSQL') OR MATCH (titleAGAINST ('Tricks'); // OR ........... 
    I'm wondering if there is a better way.
    What do you about it ?

  2. #2
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and what's about
    PHP Code:
    SELECT idtitleMATCH (titleAGAINST ('My cool question .....') AS score 
    FROM cc_question WHERE MATCH 
    (titleAGAINST ('My cool question .....'); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •