我的表象是:
.poll_users
(id int(11) NOT NULL AUTO_INCREMENT
name VARCHAR(255) NOT NULL
PRIMARY KEY (id))
.poll_referendum
(id int(11) NOT NULL AUTO_INCREMENT
name varchar(255) DEFAULT NULL
PRIMARY KEY (id))
.poll_questions
id int(11) NOT NULL AUTO_INCREMENT
referendum_id int(11) DEFAULT NULL
body varchar(255) DEFAULT NULL
created_at datetime DEFAULT NULL
updated_at datetime DEFAULT NULL
PRIMARY KEY (`id`)
KEY `referendum_id` (`referendum_id`))
.poll_answers
`id` int(11) NOT NULL AUTO_INCREMENT
`vote_id` int(11) DEFAULT 0
`question_id` int(11) NOT NULL
`created_at` datetime DEFAULT NULL
`updated_at` datetime DEFAULT NULL
PRIMARY KEY (`id`)
KEY `vote_id` (`vote_id`)
KEY `question_id` (`question_id`))
.poll_voting
`id` int(11) NOT NULL AUTO_INCREMENT
`question_id` int(11) NOT NULL DEFAULT 0
`answer_id` int(11) NOT NULL DEFAULT 0
`user_id` int(11) NOT NULL DEFAULT 0
`created_at` datetime DEFAULT NULL
`updated_at` datetime DEFAULT NULL
PRIMARY KEY (`id`)
KEY `question_id` (`question_id`)
KEY `answer_id` (`answer_id`)
KEY `user_id` (`user_id`))
.vote_types
`id` int(11) NOT NULL AUTO_INCREMENT
`type` varchar(255) DEFAULT NULL
PRIMARY KEY (`id`))
我怎么能够选择投票类型——类型表,与适当的问答和调查相对应?
I have tried: SELECT vote_id FROM surveys.poll_answers WHERE question_id = 1;
but this gives me:
and 1,2 are indexes to the vote type text SELECT *
FROM
surveys.
vote_types
WHERE
id=1
In poll_answers table I keep indexes what vote types are assigned to questions and questions are assigned to proper referendums in poll_referendum table
so how do I fetch those vote types corresponing to proper question and survey
like
SELECT vote_id indexes from poll_answers table and they index to vote_types where are stored vote types in text and those vote_types corresponds to proper questions that are stored in poll_questions and referendums that are stored in poll_referendum ?
感谢您的帮助