Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 0.41 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to perform same query on two different tables in one query
  2. SELECT `id`
  3. FROM (`videos`)
  4. WHERE  `name`  LIKE '%Dragon Ball Z (U.S.)%'
  5.        
  6. SELECT `vid_id` as id
  7. FROM (`other_names`)
  8. WHERE  `name`  LIKE '%Dragon Ball Z (U.S.)%'
  9. GROUP BY `vid_id`
  10.        
  11. SELECT `id`
  12. FROM (`videos`)
  13. WHERE  `name`  LIKE '%Dragon Ball Z (U.S.)%'
  14. UNION
  15. SELECT `vid_id` as id
  16. FROM (`other_names`)
  17. WHERE  `name`  LIKE '%Dragon Ball Z (U.S.)%'