Guest User

Untitled

a guest
Jan 13th, 2018
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.14 KB | None | 0 0
  1. SELECT id as intent_id FROM `tbl_intent` WHERE `name` = 'Car'
  2. SELECT id as slot_id1 FROM `tbl_slot` WHERE `name` = '2018'
  3. SELECT id as slot_id2 FROM `tbl_slot` WHERE `name` = 'Chevrolet'
  4. SELECT id as slot_id3 FROM `tbl_slot` WHERE `name` = 'Corvette'
  5.  
  6. SELECT
  7. *,
  8. output_id
  9. FROM xref_intent_slot
  10. LEFT JOIN tbl_slot slot1 ON xref_intent_slot.slot_id=slot1.id AND slot1.name='2018'
  11. LEFT JOIN tbl_slot slot2 ON xref_intent_slot.slot_id=slot2.id AND slot2.name='Chevrolet'
  12. LEFT JOIN tbl_slot slot3 ON xref_intent_slot.slot_id=slot3.id AND slot3.name='Corvette'
  13.  
  14.  
  15. +----+-----------+-----------+---------+------+------+------+-----------+------+----------+-----------+
  16. | id | output_id | intent_id | slot_id | id | name | id | name | id | name | output_id |
  17. +----+-----------+-----------+---------+------+------+------+-----------+------+----------+-----------+
  18. | 1 | 1 | 1 | 1 | 1 | 2018 | NULL | NULL | NULL | NULL | 1 |
  19. | 2 | 1 | 1 | 2 | NULL | NULL | 2 | Chevrolet | NULL | NULL | 1 |
  20. | 3 | 1 | 1 | 3 | NULL | NULL | NULL | NULL | 3 | Corvette | 1 |
  21. | 4 | 2 | 1 | 4 | NULL | NULL | NULL | NULL | NULL | NULL | 2 |
  22. | 5 | 2 | 1 | 2 | NULL | NULL | 2 | Chevrolet | NULL | NULL | 2 |
  23. | 6 | 2 | 1 | 5 | NULL | NULL | NULL | NULL | NULL | NULL | 2 |
  24. +----+-----------+-----------+---------+------+------+------+-----------+------+----------+-----------+
  25.  
  26. +-------------------+
  27. | tbl_intent |
  28. | tbl_output |
  29. | tbl_slot |
  30. | xref_intent_slot |
  31. +-------------------+
  32.  
  33. +-------+--------------+------+-----+---------+----------------+
  34. | Field | Type | Null | Key | Default | Extra |
  35. +-------+--------------+------+-----+---------+----------------+
  36. | id | int(11) | NO | PRI | NULL | auto_increment |
  37. | name | varchar(255) | NO | MUL | NULL | |
  38. +-------+--------------+------+-----+---------+----------------+
  39.  
  40. +----+------+
  41. | id | name |
  42. +----+------+
  43. | 1 | Car |
  44. +----+------+
  45.  
  46. +-------+--------------+------+-----+---------+----------------+
  47. | Field | Type | Null | Key | Default | Extra |
  48. +-------+--------------+------+-----+---------+----------------+
  49. | id | int(11) | NO | PRI | NULL | auto_increment |
  50. | name | varchar(255) | NO | MUL | NULL | |
  51. +-------+--------------+------+-----+---------+----------------+
  52.  
  53. +----+-----------+
  54. | id | name |
  55. +----+-----------+
  56. | 1 | 2018 |
  57. | 2 | Chevrolet |
  58. | 3 | Corvette |
  59. | 4 | 2017 |
  60. | 5 | Camaro |
  61. +----+-----------+
  62.  
  63. +--------+---------+------+-----+---------+----------------+
  64. | Field | Type | Null | Key | Default | Extra |
  65. +--------+---------+------+-----+---------+----------------+
  66. | id | int(11) | NO | PRI | NULL | auto_increment |
  67. | output | text | NO | | NULL | |
  68. +--------+---------+------+-----+---------+----------------+
  69.  
  70. +----+----------------+
  71. | id | output |
  72. +----+----------------+
  73. | 1 | Found Corvette |
  74. | 2 | Found Camaro |
  75. +----+----------------+
  76.  
  77. +-----------+---------+------+-----+---------+----------------+
  78. | Field | Type | Null | Key | Default | Extra |
  79. +-----------+---------+------+-----+---------+----------------+
  80. | id | int(11) | NO | PRI | NULL | auto_increment |
  81. | output_id | int(11) | NO | | NULL | |
  82. | intent_id | int(11) | NO | | NULL | |
  83. | slot_id | int(11) | NO | | NULL | |
  84. +-----------+---------+------+-----+---------+----------------+
  85.  
  86. +----+-----------+-----------+---------+
  87. | id | output_id | intent_id | slot_id |
  88. +----+-----------+-----------+---------+
  89. | 1 | 1 | 1 | 1 |
  90. | 2 | 1 | 1 | 2 |
  91. | 3 | 1 | 1 | 3 |
  92. | 4 | 2 | 1 | 4 |
  93. | 5 | 2 | 1 | 2 |
  94. | 6 | 2 | 1 | 5 |
  95. +----+-----------+-----------+---------+
Add Comment
Please, Sign In to add comment