У меня есть следующие 2 таблицы ..
mysql> describe catalog_category_reference;
+----------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | text | NO | | NULL | |
| class_id | text | NO | | NULL | |
+----------+---------+------+-----+---------+----------------+
и
mysql> describe product_import_queue;
+-----------------------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| unique_id | text | NO | | NULL | |
| category_code | text | NO | | NULL | |
| item_code | text | NO | | NULL | |
| ffl_flag | int(11) | NO | | NULL | |
| name | text | NO | | NULL | |
| price | text | NO | | NULL | |
| image | text | NO | | NULL | |
| custom_options_flag | int(11) | NO | | NULL | |
| custom_options_string | text | NO | | NULL | |
| short_desc | text | NO | | NULL | |
| long_desc | text | NO | | NULL | |
| process_status | int(11) | NO | | 0 | |
+-----------------------+---------+------+-----+---------+----------------+
Я хочу выполнить поиск по product_import_queue и найти "код_категории", которых нет в каталоге catalog_Category_reference Обратите внимание, что category_code
хранится в таблице catalog_reference под class_id
. Могу ли я сделать это одним запросом? Я пытался что-то вроде ...
SELECT category_code FROM product_import_queue
LEFT JOIN catalog_category_reference ON product_import_queue.category_code = catalog_category_reference.class_id;
Но это не то, что я ищу, и я еще не полностью понимаю JOIN.