Jump to content

slkhlaw

Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

slkhlaw's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. SELECT Title, Body, MATCH (Title, Body) AGAINST ($SearchString) AS Relevancy FROM articles WHERE MATCH (Title, Body) AGAINST ($SearchString) ORDER BY Relevancy DESC LIMIT 100; Add more conditions if you need to before the "ORDER BY", e.g. Author='Peter' You may have to change your database engine if your current engine does not support Full Text Search. Also be sure to index your table for full text search and use LIMIT command. When your database grew to a few million records, the retrieval time for each search between using index+limit and not using index+limit is 1 sec vs 20 min.
  2. I have the following table Table User UID FirstName LastName Table Email UID Email-ID EmailAddress Table Telephone UID Telephone ID Telephone Table Fax UID Fax-ID Fax I would like do two things 1) Output all UID, FirstName, LastName, EmailAddress, Telephone, Fax in one output. How do I do that? 2) Output UID, FirstName, LastName, EmailAddress, Telephone, Fax with given UID in one output. How do I do that? (One user may have multiple Telephone, Email address and Fax) I would appreciate if anyone could lend me a hand in this. Thank you very much indeed.
  3. I came to a stumble block while trying to design my database. Two problems basically. I hope someone could lend me a hand. 1) I am trying to categorise my stuff into 3 generations of categories (Eg. Main category, Sub category, sub-subcategory). And would like to keep the option open to further sub divide them into 4 generations or more in the future if deemed necessary. My current table looks like this, I don't know how to normalise from here onwards. Table Item Item-ID - PK Title Description Location (Cities, Countries, Continents) SubSubCategory SubCategory MainCategory What eventually I want to have is a main page which list all the maincategory. When user click to look at a particular main category, all the subcategory will be displayed. And when the user click on the subcategory, all the subsubcategory will be displayed. When the user click further, all the items from the same subsubcategory will be displayed. (A bit like Ebay's category) 2) Second problem also related to the above table. Location will be dependent on Cities, Countries and Continents. And all the three are related with one another. A bit like subcategory problem above. What basically I want to achieve here is that when a user would like to search by location, i.e. closest cities to him, or the countries he is in. Or within certain continent (i.e. Europe). Actually I am more comfortable with flat table in this instance, but I can imagine there will be massive amount of duplication. Can someone help me?
  4. Works like a charm! Thanks. I substitute "OR" with "XOR" to make sure Peter I meant wasn't a Noobie. Thank you so much. [!--quoteo(post=321336:date=Nov 23 2005, 06:43 AM:name=shoz)--][div class=\'quotetop\']QUOTE(shoz @ Nov 23 2005, 06:43 AM) 321336[/snapback][/div][div class=\'quotemain\'][!--quotec--] [!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] id, title, description from articles where match (title,description) against ('searchstring') AND PostedDate BETWEEN '2005[span style=\'color:orange\']-01-02'[/span] AND '2005[span style=\'color:orange\']-10-1'[/span] AND (AuthorRank != 'Noobie' or Author='Peter') [!--sql2--][/div][!--sql3--] You may need to change the last condition depending on what exactly you're looking for. The last condition currently says that you'd like to get results if AuthorRank != 'Noobie', but if Author = 'Peter' you'd still like results even if the AuthorRank is 'Noobie'
  5. I got a bit lost with full text search using MySQL. I hope someone could help me. I am trying to search and display id, title, description from a database with additional condition to it. Could someone help me? SELECT id, title, description from articles where match (title,description) against ('searchstring'); Where do I put the additional conditions say, I want it to search for PostedDate > 1/1/2005 and not later than 1/10/2005 and (AuthorRank != 'Noobie' or Author='Peter')?
×
×
  • 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.