会员表:
CREATE TABLE `Consultant_Memberships` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`membership_url` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
Memberships_List 表:
CREATE TABLE `Consultant_Memberships_List` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`consultant_id` int(11) DEFAULT NULL,
`membership_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
在成员资格表中,有一个成员可以成为其中一部分的“社团”列表。选择后,它会以以下形式添加到“Memberships_List”中:
- id - 自动递增
- advisor_id - 添加社团的用户的唯一 ID
- member_id - 指会员表中的“id”。
我希望能够在下拉列表中仅显示用户尚未选择的成员资格。到目前为止,我有:
$query = $db->query("SELECT `Consultant_Memberships.`id`, `Consultant_Memberships`.`title` `FROM `Consultant_Memberships
WHERE NOT EXISTS (SELECT `Consultant_Memberships`.`id`, `Consultant_Memberships`.`title`
WHERE `Consultant_Memberships`.`id` = $user_id)");
我目前收到此错误,也不确定这是否是正确的查询:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `Consultant_Memberships_List`.`id` = )' at line 1' in /Users/Sites/pages/medical.php:72
Stack trace:
#0 /Users/Sites/pages/medical.php(72): PDO->query('SELECT `Consult...')
#1 /Users/Sites/index.php(18): include('/Users/Site...')
#2 {main}
thrown in /Users/Sites/pages/medical.php on line 72