November 3rd, 2000, 03:30 PM
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).]
November 3rd, 2000, 04:58 PM
<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?
November 4th, 2000, 12:25 AM
the actual string goes something like this...
$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.
November 4th, 2000, 01:39 AM
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:
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;