When to Use "like" or "="?

Results 1 to 2 of 2

Thread: When to Use "like" or "="?

  1. #1
    Join Date
    Dec 1969

    Default When to Use "like" or "="?

    Hi! I&#039;ve been wondering about this for a while, but I haven&#039;t been able to find any documentation about it, anywhere. So...<BR><BR>When you&#039;re writing SQL queries and such, when is it more appropriate to use "like" rather than "=", and vice-versa?<BR><BR>Thanks,<BR><BR>Defiant005

  2. #2
    Join Date
    Dec 1969

    Default Only use LIKE with wild cards

    Suppose you have these values in your name field in your db:<BR> Johnson<BR> Onager<BR> Monroe<BR><BR>Now is you do<BR> WHERE name LIKE &#039;%on%&#039;<BR>you match <BR> Johnson<BR> Onager<BR> Monroe<BR><BR>If you do <BR> WHERE name LIKE &#039;%on&#039;<BR>you match <BR> Johnson<BR><BR>If you do <BR> WHERE name LIKE &#039;on%&#039;<BR>you match <BR> Onager<BR><BR>But if you use = you can only match one of them, and then only *exactly*.<BR> WHERE name = &#039;monro&#039;<BR>matches *none* of them.<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts