我在数据库中查询具有联合相关表的表 示例:我想显示所有样式并使用该样式连接混合,但如果样式没有混合,则显示0混音。
这是我的2张桌子:
CREATE TABLE `mixes` (
`mixes_id` int(11) NOT NULL AUTO_INCREMENT,
`datePublic` date DEFAULT NULL ,
`timeLenght` time DEFAULT NULL ,
`Title` varchar(255) DEFAULT 'No-Title-Yet' ,
`dwnlSize` varchar(45) DEFAULT '? MegaBytes',
`Quality` char(10) DEFAULT '? kbits/s',
`style_id` int(3) unsigned zerofill DEFAULT NULL,
`collection_id` int(3) unsigned zerofill DEFAULT '001',
`lienDwnld` varchar(255) DEFAULT NULL,
`VidLink` varchar(255) DEFAULT NULL,
`ArtisteFeat` varchar(255) DEFAULT NULL,
`slugMixTitle` varchar(100) DEFAULT NULL,
`cache` enum('0','1') DEFAULT NULL,
PRIMARY KEY (`mixes_id`),
UNIQUE KEY `Title_UNIQUE` (`Title`),
UNIQUE KEY `lienDwnld_UNIQUE` (`lienDwnld`),
UNIQUE KEY `slugMixTitle` (`slugMixTitle`),
KEY `style_index` (`style_id`),
KEY `collection_index` (`collection_id`)
)
ENGINE=InnoDB DEFAULT CHARSET=latin1 ;
ALTER TABLE `mixes`
ADD CONSTRAINT `collectionMustExist` FOREIGN KEY (`collection_id`) REFERENCES `collection` (`collection_id`),
ADD CONSTRAINT `styleMustExist` FOREIGN KEY (`style_id`) REFERENCES `style` (`style_id`);
CREATE TABLE `style` (
`style_id` int(3) unsigned zerofill NOT NULL AUTO_INCREMENT,
`imgMixCat` varchar(255) DEFAULT NULL,
`nameMixCat` varchar(45) DEFAULT NULL,
`descMixCat` varchar(255) DEFAULT NULL,
`slugMixCat` varchar(45) DEFAULT NULL,
`hideMixCat` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`style_id`),
UNIQUE KEY `nameMixCat_UNIQUE` (`nameMixCat`),
UNIQUE KEY `slugMixCat` (`slugMixCat`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ;
SELECT
count(style.style_id) AS count,
nameMixCat,
style.style_id,
descMixCat,
hideMixCat,
slugMixCat,
imgMixCat
FROM style as style
LEFT JOIN mixes as mixes ON style.style_id = mixes.style_id
GROUP BY style.style_id
ORDER BY style.style_id ASC
那么当没有与样式相关的混音时,返回1会是什么?