Results 1 to 5 of 5

Thread: SQL help required!

  1. #1
    Taz
    Taz is offline
    Senior Member Taz's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    2,111
    Thanks
    49
    Thanked
    26 times in 25 posts
    • Taz's system
      • Motherboard:
      • Gigabyte Z270 HD3P
      • CPU:
      • Intel Core i5 7600K
      • Memory:
      • Corsair CMK16GX4M2B3200C16R Vengeance LPX 16 GB
      • Storage:
      • Samsung 960 EVO M.2-2280 500GB (PCIe) + 1TB Sandisk Ultra II SSD (SATA)
      • Graphics card(s):
      • Asus NVIDIA GeForce GTX 1070 OC
      • PSU:
      • Corsair CS550M 550W Hybrid
      • Case:
      • NZXT Source 340
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • 34" Asus Designo Curve MX34VQ UWQHD Monitor
      • Internet:
      • Virgin Media Vivid 200

    SQL help required!

    If anyone is a SQL guru then you may be able to help me out. I'm trying to write a SQL query to return IP addresses in the range '10.1.*' - that is, any IP addresses that begin with '10.1.' followed by anything.

    However, I believe that entering '10.1.*' as the search criteria in my SQL query will interpret the '.*' as a wildcard rather than taking the '.' before the '*' as a literal character.

    So, what should my search string be to take the second '.' as a literal character followed by any characters

  2. #2
    Senior Member
    Join Date
    Sep 2005
    Posts
    524
    Thanks
    38
    Thanked
    40 times in 34 posts
    Which version of sql are you using?

    I only know oracle sql I'm afraid, and neither . or * is a wildcard as far as I know.

    The wildcard characters are _ (to match single character) and % (to match multiple characters).

    so you would want something like:
    where ip like '10.1.%'

    or alternativley you could avoid wildcards altogether by using something like:
    where substr(ip,1,5) = '10.1.'

  3. #3
    Taz
    Taz is offline
    Senior Member Taz's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    2,111
    Thanks
    49
    Thanked
    26 times in 25 posts
    • Taz's system
      • Motherboard:
      • Gigabyte Z270 HD3P
      • CPU:
      • Intel Core i5 7600K
      • Memory:
      • Corsair CMK16GX4M2B3200C16R Vengeance LPX 16 GB
      • Storage:
      • Samsung 960 EVO M.2-2280 500GB (PCIe) + 1TB Sandisk Ultra II SSD (SATA)
      • Graphics card(s):
      • Asus NVIDIA GeForce GTX 1070 OC
      • PSU:
      • Corsair CS550M 550W Hybrid
      • Case:
      • NZXT Source 340
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • 34" Asus Designo Curve MX34VQ UWQHD Monitor
      • Internet:
      • Virgin Media Vivid 200
    It's a query into MS SQL Server 2000. I think you're right though. I'll use '%' instead of '*'.

  4. #4
    awm
    awm is offline
    Senior Member
    Join Date
    Apr 2006
    Location
    US
    Posts
    920
    Thanks
    4
    Thanked
    7 times in 7 posts
    Can you put a \ in front of the . to have SQL take it literly. I know I have to do that for quotes.

  5. #5
    Flower Child stytagm's Avatar
    Join Date
    Aug 2004
    Location
    London
    Posts
    754
    Thanks
    47
    Thanked
    23 times in 18 posts
    You also need to use the Keyword "Like". So...
    Code:
    where ipAddress like '10.10.%'
    They told me I was gullible ... and I believed them.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Final SQL problem - but it ain't too easy
    By Bazzlad in forum Software
    Replies: 4
    Last Post: 28-07-2006, 10:10 AM
  2. Member Database SQL / PHP
    By realm in forum Software
    Replies: 4
    Last Post: 03-01-2006, 06:48 PM
  3. SQL Server 2000
    By Fatboy in forum Software
    Replies: 37
    Last Post: 17-08-2005, 07:05 PM
  4. SQL Server Connection string?
    By Stoo in forum Software
    Replies: 7
    Last Post: 04-05-2005, 05:48 PM
  5. Learning SQl - oracle download?
    By PanzerKnight in forum Software
    Replies: 13
    Last Post: 29-07-2004, 07:11 PM

Posting Permissions

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