Guest User

Untitled

a guest
Aug 14th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. How to get all records NOT found from query and how to do a word search from Excel list? [closed]
  2. SELECT <fields>
  3. FROM Table1
  4. WHERE Field1 NOT IN (SELECT Field1 FROM Query1)
  5.  
  6. SELECT DISTINCT temp.id, temp.name
  7. FROM(
  8. ( /* your first query */
  9. SELECT table1.id AS id, table1.name AS name
  10. FROM mytable AS table1
  11. WHERE (CONDIDION)
  12. )
  13. UNION /* combine both queries, make sure their columns match */
  14. ( /* your second query with the records not included in the first */
  15. SELECT table2.id AS id, table2.name AS name
  16. FROM mytable AS table2
  17. WHERE (CONDIDION)
  18. )
  19. ) AS temp;
  20.  
  21. SELECT DISTINCT temp.id, temp.name
  22. FROM(
  23. ( /* select all rows in your first table */
  24. SELECT table1.id AS id, table1.name AS name
  25. FROM mytable AS table1
  26. )
  27. EXCEPT /* use except or your language equivalent */
  28. /*make sure their columns match */
  29. ( /* put your first query here */
  30. SELECT table2.id AS id, table2.name AS name
  31. FROM mytable AS table2
  32. WHERE (CONDIDION)
  33. )
  34. ) AS temp;
Add Comment
Please, Sign In to add comment