{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/10375","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/10375/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/10375/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/10375/events","html_url":"https://github.com/yiisoft/yii2/issues/10375","id":121806954,"number":10375,"title":"viaTable() executing: SELECT * FROM `x` WHERE (`0`, `1`) IN (('1', '1'))","user":{"login":"BenasPaulikas","id":6473565,"avatar_url":"https://avatars.githubusercontent.com/u/6473565?v=3","gravatar_id":"","url":"https://api.github.com/users/BenasPaulikas","html_url":"https://github.com/BenasPaulikas","followers_url":"https://api.github.com/users/BenasPaulikas/followers","following_url":"https://api.github.com/users/BenasPaulikas/following{/other_user}","gists_url":"https://api.github.com/users/BenasPaulikas/gists{/gist_id}","starred_url":"https://api.github.com/users/BenasPaulikas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenasPaulikas/subscriptions","organizations_url":"https://api.github.com/users/BenasPaulikas/orgs","repos_url":"https://api.github.com/users/BenasPaulikas/repos","events_url":"https://api.github.com/users/BenasPaulikas/events{/privacy}","received_events_url":"https://api.github.com/users/BenasPaulikas/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:need%20more%20info","name":"status:need more info","color":"d4c5f9"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-12-11T22:46:32Z","updated_at":"2015-12-11T23:50:59Z","closed_at":null,"body":"When executing this:\r\n```\r\nreturn $this->hasMany(Category::className(), ['cat_id', 'cat_id'])\r\n   ->viaTable(ArtistCategory::tableName(), ['artist_id' => 'artist_id']);\r\n```\r\nI get this exception:\r\n```\r\n      The SQL being executed was: SELECT * FROM `category` WHERE (`0`, `1`) IN (('1', '1'))\r\n```\r\n\r\nTables:\r\n```\r\n      category(cat_id)\r\n      artist_category(artist_id, cat_id)\r\n```\r\n\r\nP.S.\r\n    SELECT * FROM `artist_category` WHERE `artist_id`=2\r\nreturns 1 row(artist_id:2, cat_id:1)"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/164083196","html_url":"https://github.com/yiisoft/yii2/issues/10375#issuecomment-164083196","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/10375","id":164083196,"user":{"login":"BenasPaulikas","id":6473565,"avatar_url":"https://avatars.githubusercontent.com/u/6473565?v=3","gravatar_id":"","url":"https://api.github.com/users/BenasPaulikas","html_url":"https://github.com/BenasPaulikas","followers_url":"https://api.github.com/users/BenasPaulikas/followers","following_url":"https://api.github.com/users/BenasPaulikas/following{/other_user}","gists_url":"https://api.github.com/users/BenasPaulikas/gists{/gist_id}","starred_url":"https://api.github.com/users/BenasPaulikas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BenasPaulikas/subscriptions","organizations_url":"https://api.github.com/users/BenasPaulikas/orgs","repos_url":"https://api.github.com/users/BenasPaulikas/repos","events_url":"https://api.github.com/users/BenasPaulikas/events{/privacy}","received_events_url":"https://api.github.com/users/BenasPaulikas/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T23:50:59Z","updated_at":"2015-12-11T23:50:59Z","body":"It's MySQL. After adding these tables generate 3 models: Category, Artist,  ArtistCategory and add this snippet to Artist model, then run Artis::find()->where(['artist_id' => 2])->categories\r\n```\r\npublic function getCategories()\r\n{\r\nreturn $this->hasMany(Category::className(), ['cat_id', 'cat_id'])\r\n   ->viaTable(ArtistCategory::tableName(), ['artist_id' => 'artist_id']);\r\n}\r\n```\r\n\r\n```\r\nCREATE TABLE IF NOT EXISTS `category` (\r\n  `cat_id` int(10) NOT NULL AUTO_INCREMENT,\r\n  `group_id` int(6) NOT NULL,\r\n  PRIMARY KEY (`cat_id`,`group_id`),\r\n  UNIQUE KEY `cat_id_UNIQUE` (`cat_id`)\r\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17 ;\r\n\r\nINSERT INTO `category` (`cat_id`, `group_id`) VALUES\r\n(1, 1);\r\n\r\nCREATE TABLE IF NOT EXISTS `artist_category` (\r\n  `artist_id` int(10) NOT NULL,\r\n  `cat_id` int(10) NOT NULL,\r\n  PRIMARY KEY (`artist_id`,`cat_id`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\r\n\r\nINSERT INTO `artist_category` (`artist_id`, `cat_id`) VALUES\r\n(2, 1);\r\n\r\nCREATE TABLE IF NOT EXISTS `artist` (\r\n  `artist_id` int(10) NOT NULL AUTO_INCREMENT,\r\n  `author_id` int(10) NOT NULL,\r\n  PRIMARY KEY (`artist_id`,`author_id`),\r\n  UNIQUE KEY `artist_id_UNIQUE` (`artist_id`)\r\n) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;\r\n\r\nINSERT INTO `artist` (`artist_id`, `author_id`) VALUES\r\n(2, 28);\r\n\r\n```"}}