clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 648468 fiddles created (15192 in the last week).

CREATE TABLE `phone_directory` ( `lead_id` INT(9) UNSIGNED NOT NULL AUTO_INCREMENT, `list_id` BIGINT(14) UNSIGNED DEFAULT NULL, `gmt_offset_now` DECIMAL(4,2) DEFAULT '0.00', `first_name` VARCHAR(30) DEFAULT NULL, `middle_initial` CHAR(1) DEFAULT NULL, `last_name` VARCHAR(30) DEFAULT NULL, `address1` VARCHAR(100) DEFAULT NULL, `address2` VARCHAR(100) DEFAULT NULL, `address3` VARCHAR(100) DEFAULT NULL, `city` VARCHAR(50) DEFAULT NULL, `state` CHAR(2) DEFAULT NULL, `postal_code` VARCHAR(10) DEFAULT NULL, `email` VARCHAR(70) DEFAULT NULL, `fax_number` VARCHAR(255) DEFAULT NULL, `manager_name` VARCHAR(255) DEFAULT NULL, `status` VARCHAR(6) DEFAULT NULL, PRIMARY KEY (`lead_id`) ) ENGINE=INNODB DEFAULT CHARSET=utf8;
 hidden batch(es)


CREATE TABLE phones ( lead_id INT(9) NOT NULL REFERENCES phone_directory(lead_id), priority smallint NOT NULL, -- If you need to give them priorities (1, 2, 3, ...), or sort them phone VARCHAR(12) NOT NULL COLLATE latin1_bin, CONSTRAINT unique_phones UNIQUE(phone), -- You don't want repetead telephones. This enforces it. PRIMARY KEY(phone, lead_id) -- Covering index + clustering... for the sake of efficiency ) ;
 hidden batch(es)


EXPLAIN SELECT lead_id FROM phones WHERE phone IN ('315XXXXXXX','0315XXXXXXX');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE phones index PRIMARY,unique_phones PRIMARY 18 1 Using where; Using index
 hidden batch(es)