How Can i Create This Complicated Query ?
        Posted  
        
            by mTuran
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by mTuran
        
        
        
        Published on 2010-06-05T14:40:05Z
        Indexed on 
            2010/06/05
            14:42 UTC
        
        
        Read the original article
        Hit count: 319
        
Hi, I have 3 tables: projects, skills and project_skills. In projects table i hold project's general data. Second table skills i hold skill id and skill name also i have projects_skills table which is hold project's skill relationships. Here is scheme of tables:
CREATE TABLE IF NOT EXISTS `project_skills` (
  `project_id` int(11) NOT NULL,
  `skill_id` int(11) NOT NULL,
  KEY `project_id` (`project_id`),
  KEY `skill_id` (`skill_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci;
CREATE TABLE IF NOT EXISTS `projects` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `employer_id` int(11) NOT NULL,
  `project_title` varchar(100) COLLATE utf8_turkish_ci NOT NULL,
  `project_description` text COLLATE utf8_turkish_ci NOT NULL,
  `project_budget` int(11) NOT NULL,
  `project_allowedtime` int(11) NOT NULL,
  `project_deadline` datetime NOT NULL,
  `total_bids` int(11) NOT NULL,
  `average_bid` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `active` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `created` (`created`),
  KEY `employer_id` (`employer_id`),
  KEY `active` (`active`),
  FULLTEXT KEY `project_title` (`project_title`,`project_description`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci AUTO_INCREMENT=3 ;
CREATE TABLE IF NOT EXISTS `skills` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `category` int(11) NOT NULL,
  `name` varchar(100) COLLATE utf8_turkish_ci NOT NULL,
  `seo_name` varchar(100) COLLATE utf8_turkish_ci NOT NULL,
  `total_projects` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `seo_name` (`seo_name`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci AUTO_INCREMENT=224 ;
I want to select projects with related skill names. I think i have to use JOIN but i don't know how can i do. Thanks
© Stack Overflow or respective owner