create database bug9777 /*!40100 DEFAULT CHARACTER SET utf8 */; use bug9777; CREATE TABLE `client` ( `id` bigint(20) NOT NULL auto_increment, `code` varchar(20) character set utf8 collate utf8_bin NOT NULL default '', `company_name` varchar(250) character set utf8 collate utf8_bin default NULL, `company_size` int(11) default NULL, `phone` varchar(20) character set utf8 collate utf8_bin default NULL, `referrer` varchar(250) character set utf8 collate utf8_bin default NULL, `address1` varchar(250) character set utf8 collate utf8_bin default NULL, `address2` varchar(250) character set utf8 collate utf8_bin default NULL, `address3` varchar(250) character set utf8 collate utf8_bin default NULL, `city` varchar(100) character set utf8 collate utf8_bin default NULL, `state` varchar(60) character set utf8 collate utf8_bin default NULL, `zip` varchar(60) character set utf8 collate utf8_bin default NULL, `country` varchar(250) character set utf8 collate utf8_bin default NULL, `service_level` varchar(250) character set utf8 collate utf8_bin default NULL, `setup_mode` tinyint(4) default NULL, `start_date` datetime default NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `admin_user` ( `id` bigint(20) NOT NULL auto_increment, `email` varchar(250) character set utf8 collate utf8_bin default NULL, `name` varchar(250) character set utf8 collate utf8_bin default NULL, `client_id` bigint(20) default NULL, `password` varchar(250) character set utf8 collate utf8_bin default NULL, `primary_contact` tinyint(4) NOT NULL default '0', `email_opt_in` tinyint(4) NOT NULL default '1', PRIMARY KEY (`id`), UNIQUE KEY `email` (`email`), KEY `client_id` (`client_id`), CONSTRAINT `admin_user_fk1` FOREIGN KEY (`client_id`) REFERENCES `client` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; insert into client values (1, 'demo', 'Demo S', -1, 'na', '', 'na', 'na', NULL, 'na', 'na', 'na', 'UNITED STATES', NULL, 0, current_date()); insert into client(id, code, company_name, setup_mode, start_date) values (2, 'code2', 'Name 2', 0, current_date()); insert into client(id, code, company_name, setup_mode, start_date) values (3, 'code3', 'Name 3', 0, current_date()); insert into admin_user values (2, 'email1', 'name1', 3, 'password1', 0, 0); insert into admin_user values (3, 'email2', 'name1', 1, 'password2', 1, 0); insert into admin_user values (5, 'email3', 'name3', 2, 'password3', 0, 0); prepare stmt1 from 'SELECT t0_u.id FROM admin_user t0_u, client t1_u_client WHERE (t1_u_client.id = ? AND t0_u.client_id=t1_u_client.id)'; set @a = 1; execute stmt1 using @a; SELECT t0_u.id FROM admin_user t0_u, client t1_u_client WHERE (t1_u_client.id = 1 AND t0_u.client_id=t1_u_client.id); -- -- here's the last lines of the output that i got on my machine: -- -- -- mysql> prepare stmt1 from 'SELECT t0_u.id FROM admin_user t0_u, client t1_u_client WHERE (t1_u_client.id = ? AND t0_u.client_id=t1_u_client.id)'; -- Query OK, 0 rows affected (0.00 sec) -- Statement prepared -- -- mysql> set @a = 1; -- Query OK, 0 rows affected (0.00 sec) -- -- mysql> execute stmt1 using @a; -- Empty set (0.00 sec) -- -- mysql> -- mysql> SELECT t0_u.id FROM admin_user t0_u, client t1_u_client WHERE (t1_u_client.id = 1 AND t0_u.client_id=t1_u_client.id); -- +----+ -- | id | -- +----+ -- | 3 | -- +----+ --