Results 1 to 6 of 6

Thread: How to match MySQL result from keywords?

  1. #1
    Join Date
    Aug 2011
    Posts
    90

    How to match MySQL result from keywords?

    From the last few weeks I am working on a business listing site. In my problem, there are two tables business table (which contains the name and address descriptions etc) and keywords table (which will contain several keywords to define the business and each keywords will be separated by comma (,) ).
    My question is that suppose a user search a data, which have the unknown business name, so in this case how can I show the result which is matching with the result. And also the most effective method to inquiry both tables when user drop in the business name and like Softtech Solution (business name) and PC support (watchword) and additionally presentation a business which could have the same name and likewise presentation alternate business which has the same magic words.

  2. #2
    Join Date
    May 2008
    Posts
    913

    Re: How to match MySQL result from keywords?

    Using following code you can match the keywords of table 2 from the description column of table 1:
    Code:
    select * from table1 where description like '%keywords%'

  3. #3
    Join Date
    Mar 2010
    Posts
    106

    Re: How to match MySQL result from keywords?

    In this case I think that you will need to define the primary and foreign key relationship between table 1 and 2, this will help you in order to join and fetch records from table 2 in the context of table 1. Leet think that foreign key of table 1 is emp_id and also primary key of table 2 is dept_id or anything else applicable as per the require.

  4. #4
    Join Date
    Nov 2008
    Posts
    1,185

    Re: How to match MySQL result from keywords?

    Thanks dude, with your reply I had just answer his query that how to match keywords, in order to get matching from both the tables.

  5. #5
    Join Date
    Mar 2010
    Posts
    122

    Re: How to match MySQL result from keywords?

    I think that in your case the query will be like this:
    SELECT name, address, description

    FROM table1,table2

    WHERE emp_id=dept_id

    AND description LIKE '%keywords%';

  6. #6
    Join Date
    Mar 2010
    Posts
    170

    Re: How to match MySQL result from keywords?

    According to me, the keyword table contains the foreign key (business_id), which is business id in the business table. I want to know that will this thing is better option for querying or else there is another better approach? And also I would like to know the common field in both the tables.

Similar Threads

  1. Replies: 4
    Last Post: 24-04-2012, 07:53 AM
  2. Replies: 4
    Last Post: 13-01-2011, 01:08 AM
  3. Replies: 3
    Last Post: 07-11-2009, 09:36 PM
  4. How to combine 3 result rows in mysql
    By HAKAN in forum Software Development
    Replies: 3
    Last Post: 20-05-2009, 10:54 PM
  5. supplied argument is not a valid mysql result resource, help
    By Dr.pter in forum Software Development
    Replies: 3
    Last Post: 14-04-2009, 08:16 AM

Tags for this Thread

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
  •  
Page generated in 1,711,636,411.54301 seconds with 17 queries