Skip to content

Instantly share code, notes, and snippets.

@rohitpaulk
Created February 19, 2018 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rohitpaulk/c773b771eb53f9356f8f9de708c29c70 to your computer and use it in GitHub Desktop.
Save rohitpaulk/c773b771eb53f9356f8f9de708c29c70 to your computer and use it in GitHub Desktop.
use teamcom_shard_01;
DROP TABLE IF EXISTS contacts_test;
CREATE TABLE contacts_test (
name VARCHAR(255),
email VARCHAR(255) NOT NULL,
public TINYINT(1), -- Values are either NULL, or True
workspace_id INT(11) unsigned NOT NULL,
creator INT(11) unsigned NOT NULL
, UNIQUE KEY `only_one_public` (workspace_id, public, email)
, UNIQUE KEY `creator_and_email` (workspace_id, creator, email)
);
EXPLAIN EXTENDED SELECT *
FROM contacts_test
WHERE workspace_id = 1234
AND (creator = 1234 or public = 1)
\G;
show keys from contacts;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment