Advertisement
Guest User

Untitled

a guest
Mar 31st, 2014
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. I have this mysql setup:
  2.  
  3. *words* table
  4. +----+-----------+
  5. | id | word |
  6. +----+-----------+
  7. | 1 | curse1 |
  8. | 2 | curse2 |
  9. | 3 | niceWord1 |
  10.  
  11. *Category* table
  12. +----+-----------+
  13. | id | name |
  14. +----+-----------+
  15. | 1 | niceWords |
  16. | 2 | badWords |
  17.  
  18.  
  19. *link* table
  20. +----+--------+-------+
  21. | id | wordID | catID |
  22. +----+-----------+----+
  23. | 1 | 1 | 2 |
  24. | 2 | 2 | 2 |
  25. | 3 | 3 | 1 |
  26.  
  27. I want to make a MySQL SELECT where I say I want to select all bad words using the link table
  28. So i'll get something like this output:
  29.  
  30. +----------+------------+---------------+
  31. | words.id | words.word | Category.name |
  32. +----------+------------+---------------+
  33. | 1 | curse1 | badWords |
  34. | 2 | curse2 | badWords |
  35.  
  36.  
  37. I think I need to use JOIN of some kind, im not so good at SQL.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement