ASP / SQL... "CONTAINS" question...

Results 1 to 3 of 3

Thread: ASP / SQL... "CONTAINS" question...

  1. #1
    Join Date
    Dec 1969

    Default ASP / SQL... "CONTAINS" question...

    I&#039;m trying to figure out how to do an SQL query using ASP to access an Access DB to find out if the first three numbers of an IP address match against the first three numbers of any of the registered IP addresses on the site.<BR><BR>However, I can&#039;t do it with LIKE because that&#039;s looking for an exact match, and I can&#039;t seem to get it to recognize CONTAINS, so I&#039;m looking for any advice on what I&#039;d do.<BR><BR>Thanks.

  2. #2
    Join Date
    Dec 1969

    Default LIKE is *not* exact match...

    SELECT * FROM table WHERE IPaddress LIKE &#039;192%&#039;<BR><BR>where, of course, you substitute whatever the appropriate 3 characters are in place of the 192.<BR><BR>If you omit the %, then LIKE is an exact match. But why would you then use LIKE instead of = ??<BR><BR>There are other ways to do this, since you are using Access:<BR><BR>SELECT * FROM table WHERE Left(ipAddress,3) = &#039;192&#039;<BR><BR>I can think of a couple of other uglier ways, but surely LIKE is good enough?<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default More on Contains

    Just as a side note. CONTAINS is specific to SQL Server running Full Text Search so you won&#039;t be able to use it on Access.

Posting Permissions

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