Created
December 1, 2012 14:23
-
-
Save amadoru/4182564 to your computer and use it in GitHub Desktop.
Synonyms for Dulith
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Disclaimer: I have not run these queries against any database and the syntax is in pure SQL so adjust as it fits and ignore typos | |
Create a table like this. | |
CREATE TABLE words ( | |
id INT PRIMARY KEY NOT NULL AUTO_INCREMENT, | |
group INT NOT NULL, | |
word VARCHAR(100) NOT NULL, | |
); | |
And then insert the values. Group synonyms together and assign them the same group id. | |
INSERT INTO words(group, word) VALUES (1, "hello"); | |
INSERT INTO words(group, word) VALUES (1, "hi"); | |
INSERT INTO words(group, word) VALUES (1, "hey"); | |
INSERT INTO words(group, word) VALUES (2, "afraid"); | |
INSERT INTO words(group, word) VALUES (2, "scared"); | |
Query like this. | |
SELECT word | |
FROM words | |
WHERE group = ( | |
SELECT group | |
FROM words | |
WHERE word = "hello"); | |
Tada! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment