Note that there are some explanatory texts on larger screens.

plurals
  1. POAlways return 1 even when there is no table related object
    primarykey
    data
    text
    <p>I query my database for a table with joined related table Example: I want to show all styles and join mixes with that style but show 0 mixes if thst style don't have mixes related.</p> <p>Here is my 2 tables:</p> <h3>First The Mixes table</h3> <pre><code>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`); </code></pre> <h3>Then the style Table</h3> <pre><code>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 ; </code></pre> <h3>And this is my current Query:</h3> <pre><code>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 </code></pre> <p>So what make return 1 when there is no mixes related to a style?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload