#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    61
    Rep Power
    14
    For a hit tracking page I'm doing, I'm sorting pages by an ID number, starting at 1. I also have ID's that go into the teens and so on. The problem is, when I want to SELECT the number of hits for the page "1", it gets that page, as well as all other pages with "1" in it, including "10" and "21" and so on. Here's the command line.

    SELECT * FROM table WHERE column LIKE '%idnum%'

    I tried just doing '%idnum', but that doesn't seem to work. I've tried other things too, but have yet to get it working successfully.

    Is there anyway I can get it to only fetch those rows with exactly "1" in them?

    By the way, this id number is part of a string, so its not an INT(x) column.

    [This message has been edited by Atticus (edited November 03, 2000).]
  2. #2
  3. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>By the way, this id number is part of a string, so its not an INT(x) column.[/quote]

    What's the format of the string?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    61
    Rep Power
    14
    the actual string goes something like this...

    "index.php?page=articles&num=$idnum"

    $idnum is the id number we're talking about here. For this particular page, I'm looking at all rows with "articles" and $idnum in them using the LIKE '%%' condition. When $idnum = 1, it finds all rows where there is a "1" in the string. This happens not only with the number "1", but also with "10", "21", "12", whatever.
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    18
    No offense, but that's a silly way of setting it up. If you have to search on a specific element you should have it in a seperate field.

    Are all the strings of the type:

    index.php?page=*****&id=##

    ??

    if so, you should have the table with the field page and id.

    You can then search on id normally and concatenate the fields to get the full string:

    select concat('index.php?page=',page,'&id=',id) from table where id=$id;

Similar Threads

  1. need SQL help - one query or multiples
    By coach in forum MySQL Help
    Replies: 5
    Last Post: February 16th, 2004, 08:39 AM
  2. Codepupil
    By Adachic in forum C Programming
    Replies: 3
    Last Post: February 6th, 2004, 06:50 PM
  3. Creating some type of ASP Hardware Poll
    By darkbird in forum ASP Programming
    Replies: 0
    Last Post: February 4th, 2004, 01:44 PM
  4. Replies: 3
    Last Post: January 31st, 2004, 12:16 AM
  5. DBI warnings -- plz help
    By pranesh in forum Perl Programming
    Replies: 4
    Last Post: December 1st, 2003, 06:52 PM

IMN logo majestic logo threadwatch logo seochat tools logo