Jump to content

MYSQL statement, getting specific data from 2 tables


sc

Recommended Posts

Hi all.

I Have a list of directory companies within a database, along with a directory category table, and a category/company link table(as companies may be subscribed to more than one 'directory category').

i would like my users to be able to search for companies in my table using keyword,company name and/or location, used against columns in the 'companies' table. (this is easy, working fine)

i also want to be able to search by category as well as by any company keywords, which means detecting if a certain company_id is linked to a certain category_id in the cat_link table. How may i accomplish this? i understand using multiple table searching to some extent, but cannot work out the statement i need. Please help.

hope ive made myself clear, if not please ask me to clarify.

MY BASIC TABLE SETUP---------------

COMPANIES                    CAT_LINK                    CATEGORY
---------------------------------------------------------------
company_id                    company_id                 category_id
name(fulltext)                 category_id                  category name
address
description(fulltext)
etc


----------------------------------------

anther explanation...

a user enters a search keyword, which is used against companies.name/companies.description. User also specifies a category, so ......  results compiled for the keyword search, then THOSE results searched for companies matching the specified category (which entails looking at category_link table)


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.