KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I want to run a mysql query to select all rows from a table films where the value of the title column does not exist anywhere in all the values of another column ( collection ). Here is a simplified version of my table with content: mysql> select * from films; +----+--------------+--------------+ | id | title | collection | +----+--------------+--------------+ | 1 | Collection 1 | NULL | | 2 | Film 1 | NULL | | 3 | Film 2 | Collection 1 | +----+--------------+--------------+ Here is my query: mysql> SELECT * FROM films WHERE title NOT IN (SELECT collection FROM films); Empty set (0.00 sec) In this example, I would want to select the rows with titles Film 1 and Film 2 , but my query is returning no rows. Here is the table structure: CREATE TABLE `films` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(200) NOT NULL DEFAULT '', `collection` varchar(200) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM;
Tags (comma-separated)
Save Edits
Cancel