code_junkie

Use '=' or LIKE to compare strings in SQL

Nov 14th, 2011
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. SELECT count(*)
  2. FROM master..sysobjects as A
  3. JOIN tempdb..sysobjects as B
  4. on A.name = B.name
  5.  
  6. SELECT count(*)
  7. FROM master..sysobjects as A
  8. JOIN tempdb..sysobjects as B
  9. on A.name LIKE B.name
  10.  
  11. SELECT * FROM user WHERE login LIKE 'Test%';
  12. -- Matches
  13. -- TestUser1
  14. -- TestUser2
  15. -- TestU
  16. -- Test
  17. -- etc.
  18.  
  19. select * from people where name ilike 'JOHN'
  20.  
  21. select * from people where name ~ 'John.*'
Add Comment
Please, Sign In to add comment