Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE `saq_question` (
- `id` smallint(5) unsigned NOT NULL auto_increment,
- `url_id` varchar(20) NOT NULL,
- `question` mediumtext,
- `pci_version` varchar(10) NOT NULL,
- `qid` varchar(45) NOT NULL,
- `a` tinyint(1) NOT NULL default '0',
- `b` tinyint(1) default '0',
- `c` tinyint(1) default '1',
- `d` tinyint(1) default '1',
- `requirement` smallint(5) unsigned NOT NULL default '0',
- `saq_cat` varchar(10) NOT NULL,
- `level` int(11) NOT NULL,
- `show_answer` tinyint(4) NOT NULL default '1',
- `custom_questions_id` tinyint(4) default NULL,
- PRIMARY KEY (`id`),
- KEY `url_id` (`url_id`),
- KEY `req_version` (`requirement`,`pci_version`)
- ) ENGINE=InnoDB AUTO_INCREMENT=248 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC;
- I have a page that displays a list of questions, a user has the ability to create a custom question . if they have a custom question then that question gets displayed instead of the default question.
- My current query displays all the results. But it also displays both the default quesiton and a custom question where it exists. So for wherever a custom question exists i need it to display that one instead of the default.
- The difference between a default question and a custom question is that the custom question has a value in the custom_questions_id column.
- Here's my query
- SELECT q.custom_questions_id,q.qid,q.url_id, q.id, q.question, q.pci_version, q.a, q.b, q.c, q.d, q.requirement, q.saq_cat, q.level, q.show_answer, a.id answer_id, a.answer, a.reason from saq_question q left join saq_answer a on q.id=a.question_id and (a.profile_id=? or a.profile_id is null) where q.requirement=? and q.pci_version=? and q.saq_cat like ? and (q.custom_questions_id=? or q.custom_questions_id is null) order by q.url_id
Add Comment
Please, Sign In to add comment