Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT id as intent_id FROM `tbl_intent` WHERE `name` = 'Car'
- SELECT id as slot_id1 FROM `tbl_slot` WHERE `name` = '2018'
- SELECT id as slot_id2 FROM `tbl_slot` WHERE `name` = 'Chevrolet'
- SELECT id as slot_id3 FROM `tbl_slot` WHERE `name` = 'Corvette'
- SELECT
- *,
- output_id
- FROM xref_intent_slot
- LEFT JOIN tbl_slot slot1 ON xref_intent_slot.slot_id=slot1.id AND slot1.name='2018'
- LEFT JOIN tbl_slot slot2 ON xref_intent_slot.slot_id=slot2.id AND slot2.name='Chevrolet'
- LEFT JOIN tbl_slot slot3 ON xref_intent_slot.slot_id=slot3.id AND slot3.name='Corvette'
- +----+-----------+-----------+---------+------+------+------+-----------+------+----------+-----------+
- | id | output_id | intent_id | slot_id | id | name | id | name | id | name | output_id |
- +----+-----------+-----------+---------+------+------+------+-----------+------+----------+-----------+
- | 1 | 1 | 1 | 1 | 1 | 2018 | NULL | NULL | NULL | NULL | 1 |
- | 2 | 1 | 1 | 2 | NULL | NULL | 2 | Chevrolet | NULL | NULL | 1 |
- | 3 | 1 | 1 | 3 | NULL | NULL | NULL | NULL | 3 | Corvette | 1 |
- | 4 | 2 | 1 | 4 | NULL | NULL | NULL | NULL | NULL | NULL | 2 |
- | 5 | 2 | 1 | 2 | NULL | NULL | 2 | Chevrolet | NULL | NULL | 2 |
- | 6 | 2 | 1 | 5 | NULL | NULL | NULL | NULL | NULL | NULL | 2 |
- +----+-----------+-----------+---------+------+------+------+-----------+------+----------+-----------+
- +-------------------+
- | tbl_intent |
- | tbl_output |
- | tbl_slot |
- | xref_intent_slot |
- +-------------------+
- +-------+--------------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +-------+--------------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | name | varchar(255) | NO | MUL | NULL | |
- +-------+--------------+------+-----+---------+----------------+
- +----+------+
- | id | name |
- +----+------+
- | 1 | Car |
- +----+------+
- +-------+--------------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +-------+--------------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | name | varchar(255) | NO | MUL | NULL | |
- +-------+--------------+------+-----+---------+----------------+
- +----+-----------+
- | id | name |
- +----+-----------+
- | 1 | 2018 |
- | 2 | Chevrolet |
- | 3 | Corvette |
- | 4 | 2017 |
- | 5 | Camaro |
- +----+-----------+
- +--------+---------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +--------+---------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | output | text | NO | | NULL | |
- +--------+---------+------+-----+---------+----------------+
- +----+----------------+
- | id | output |
- +----+----------------+
- | 1 | Found Corvette |
- | 2 | Found Camaro |
- +----+----------------+
- +-----------+---------+------+-----+---------+----------------+
- | Field | Type | Null | Key | Default | Extra |
- +-----------+---------+------+-----+---------+----------------+
- | id | int(11) | NO | PRI | NULL | auto_increment |
- | output_id | int(11) | NO | | NULL | |
- | intent_id | int(11) | NO | | NULL | |
- | slot_id | int(11) | NO | | NULL | |
- +-----------+---------+------+-----+---------+----------------+
- +----+-----------+-----------+---------+
- | id | output_id | intent_id | slot_id |
- +----+-----------+-----------+---------+
- | 1 | 1 | 1 | 1 |
- | 2 | 1 | 1 | 2 |
- | 3 | 1 | 1 | 3 |
- | 4 | 2 | 1 | 4 |
- | 5 | 2 | 1 | 2 |
- | 6 | 2 | 1 | 5 |
- +----+-----------+-----------+---------+
Add Comment
Please, Sign In to add comment