Witam serdecznie
Chciałem za pomocą jednego zapytania wyciągnąć dane z trzech tabel, przy dwóch dałem sobie radę.
SELECT company.* , company_content.* FROM company INNER JOIN company_content ON company.company_id
tabela company wybieram wszystko tak samo tabela company_content, chciał bym tez z trzeciej tabelki states wyciągnąć województwo. Zapisane to jest w tabeli company w polu state_id (int) przy czym jest to nic innego jak id z tabeli states_id
--
-- Struktura tabeli dla `company`
--
CREATE TABLE `company` (
`company_id` int(11) NOT NULL AUTO_INCREMENT,
`company_name` varchar(150) NOT NULL,
`company_addr` varchar(150) NOT NULL,
`company_city` varchar(50) NOT NULL,
`state_id` smallint(6) NOT NULL,
`company_code` char(6) NOT NULL,
`company_tel` varchar(50) NOT NULL,
`company_fax` varchar(25) NOT NULL,
`company_www` varchar(50) NOT NULL,
`company_email` varchar(50) NOT NULL,
`company_skype` varchar(50) NOT NULL,
`company_industry` int(11) NOT NULL,
`company_cliks` int(11) NOT NULL,
`company_content` int(11) NOT NULL,
`company_logo` int(11) NOT NULL,
PRIMARY KEY (`company_id`),
KEY `company_industry` (`company_industry`),
KEY `company_state` (`state_id`),
KEY `company_content` (`company_content`),
KEY `company_logo` (`company_logo`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
-- --------------------------------------------------------
--
-- Struktura tabeli dla `company_content`
--
CREATE TABLE `company_content` (
`company_id` int(11) NOT NULL AUTO_INCREMENT,
`company_nip` int(11) NOT NULL,
`company_regon` int(11) NOT NULL,
`company_content` text NOT NULL,
`company_glng` varchar(25) NOT NULL,
`company_glat` varchar(25) NOT NULL,
PRIMARY KEY (`company_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
-- --------------------------------------------------------
--
-- Struktura tabeli dla `states`
--
CREATE TABLE `states` (
`state_id` smallint(6) NOT NULL AUTO_INCREMENT,
`state_name` varchar(35) character SET utf8 collate utf8_polish_ci NOT NULL,
PRIMARY KEY (`state_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;