Does anyone have any advice about how I
can get these duplicates rows out of my results array ?
If you look here: Clickbank Super Analyzer
Then just hit the Analyse Clickbank Now button
you will see these all have double entries:
ID: AFFSUPER
ID: COHYPNOSIS
ID: MAVERICK66
I want to just show one of them (the first one)
This is the script that outputs that list:
(this is just one if out of about ten) -
if($Db_recurr == "r"){
-
$sql = "SELECT * FROM clickbank WHERE (title LIKE '%$Db_search%' || descrip LIKE '%$Db_search%' )
-
AND pop > '$Db_pop_min' AND pop < '$Db_pop_max' AND grav > '$Db_grav_min' AND grav < '$Db_grav_max'
-
AND percent > '$Db_sale_pc_min' AND recurr = 't' AND totearn > '$Db_earn_min' AND cat = '$Dpcat'
-
ORDER BY $Db_sort1 DESC, $Db_sort2 DESC ";
-
} // end if
-
-
$result = mysql_query($sql)
-
or die("could not execute SELECT Clickbank". mysql_error());
-
$num = mysql_num_rows($result);
-
$Rctr = 1;
-
while($row = mysql_fetch_assoc($result)){
-
extract($row);
-
$extr = $totearn-$earn;
-
$disp1 = "<b>$Rctr) $cat</b><br>$title, <b>ID: $id</b><br>";
-
$disp2 = "$descrip<br>";
-
$disp3 = "<b>$/sale: $earn, +/mth: $rebill, Pop: $pop, Gravity: $grav, Comm%: $comm, Refers: $refer, Total Earn: $totearn</b>";
-
echo "<div style=\"width: 800px; text-align: left;\">
-
<span>$disp1</span>
-
<span>$disp2</span>
-
<span>$disp3</span>
-
<br><br>
-
</div>";
-
if($Rctr >= $Db_resp)
-
{ exit();
-
} // end if
-
$Rctr = $Rctr+1;
-
} // end while
Thanks for any help
10 2526
some possibilities:
1) don’t loop over the result set.
2) limit your sql query (SELECT … LIMIT 1)
Thanks,
I am sure you meant well, but did you
take a look at the list that script produces ?
(it is only two clicks away)
I need to loop through the result so that I can
get all of the results, I just do not want to get
the duplicate ones.
Please take a look at the output via the
link, it shows exactly what I mean.
thanks
how does it come that the duplicates have different categories then? you may try SELECT DISTINCT* (SELECT DISTINCTROW) but I’m not really sure, whether it works for you.
* - at about one fifth of the page
Thanks again for your reply.
how does it come that the duplicates have different categories then?
This happens because clickbank allows product sellers to place their products into TWO categories if they want to. That is why everything is the same except the category field.
If someone just searchs within one category then there will be no duplicates in the output list, but if you search on ALL categories, you get a lot of duplicates.
What I want to do is give an option to exclude duplicates from the listing. In that case just the first occurance will get listed.
Hope that makes sense :-)
I looked at SELECT DISTINCT but I need to focus the distinctivenes on just the ID code because within the row there are many fields that are OK to be duplicated - the category field is an obvious one.
For that reason, I started looking at the output array - hoping that maybe I could use the UNIQUE filter somehow. But I can not get it working.
Any ideas ?
but I need to focus the distinctivenes on just the ID code because within the row there are many fields that are OK to be duplicated
then fetch only the ID (there you can use SELECT DISTINCT) and get the entries in another request* (at least that’s what I would do)
* - Prepared Statements come to mind
I am sure you meant well, but did you
take a look at the list that script produces ?
(it is only two clicks away)
...
Please take a look at the output via the
link, it shows exactly what I mean.
Excuse me?! Dormilich makes two suggestions, as per your request and this is the way you answer him? I must say, I'm surprised that he even bothered to answer you after this post, something that earns him credits. I suggest that you show some respect for someone who is answering your post!
Steven
let’s put it this way, the description in the post didn’t match the situation exactly enough and I really didn’t use the link.
and I’ve read worse…
So even if you didn't use the link, I still find his reply very rude.
Sorry to upset you MrMancunian,
I certainly never meant any disrespect, I very much appreciate the help that Dormilich gives and I always thank for input given. The answer from D did suggest that the output list hadn't been seen, that is all I meant.
-----------------------------------------------------------------------------------------
then fetch only the ID (there you can use SELECT DISTINCT) and get the entries in another request* (at least that’s what I would do)
Not quite sure how to do a doubled-up query !
This is one of my queries: - if($Db_recurr == "n"){
-
$sql = "SELECT * FROM clickbank WHERE (title LIKE '%$Db_search%' || descrip LIKE '%$Db_search%' )
-
AND pop > '$Db_pop_min' AND pop < '$Db_pop_max' AND grav > '$Db_grav_min' AND grav < '$Db_grav_max'
-
AND percent > '$Db_sale_pc_min' AND recurr = 'f' AND totearn > '$Db_earn_min' AND cat = '$Dpcat'
-
ORDER BY $Db_sort1 DESC, $Db_sort2 DESC ";
-
} // end if
So how would I fit in: - $sql = "SELECT DISTINCT id FROM clickbank WHERE ???
Any explanation much appreciated.
You can also use GROUP BY.
To answer your last post, you used the * (all fields), so I don't know what the fields are in clickbank table, but you can group by the one that's duplicate... would this be "title"? if so,
put GROUP BY title at the end of your query.
Dan
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Steen |
last post by:
This is probably a silly question to most of you, but I'm in the process
of splitting off years from a large DB to several smaller ones. Some of
the existing smaller DBs already have most of the...
|
by: Richard |
last post by:
Hi Everyone,
I have a table in which their is record which is exactly same.
I want to delete all the duplicate keeping ony 1 record in a table.
Example
Table A
Empid currentmonth ...
|
by: dan graziano |
last post by:
Hi,
How do you suggest is the best way to check for duplicate rows in an
access table. And once one knows if there are duplicates, to remove all
but one.
In my access table, there are 5...
|
by: Asha |
last post by:
greetings, does anyone have any idea how to delete duplicate rows in a dataset gracefully (the fast and easy way)
|
by: Jon Maz |
last post by:
Hi,
I have a MySql problem I hope someone can help me with. I'm trying to run
an update on a linking table, the update is running into a Primary Key
constraint violation, and in my workaround...
|
by: Manish |
last post by:
The topic is related to MySQL database.
Suppose a table "address" contains the following records
-------------------------------------------------------
| name | address | phone |...
|
by: Rich |
last post by:
Hello,
I am just checking if there is a property or technique for displaying or
retrieving from a dataTable the top 1 row(s) for rows containing duplicate
keys (IDs). I have to pull data from a...
|
by: rajeshkrsingh |
last post by:
Hi friends,
Step1-
create table duplicate
(
intId int, varName varchar(50)
)
insert into duplicate(intId,varName) values(1,'rajesh')
insert into duplicate(intId,varName) values(2,'raj12')...
|
by: jamesd0142 |
last post by:
My manager and I where looking at some complex code to eliminate duplicate records in a database table.
then it hit me how its done easily... so i thought i'd share it...
In English:...
|
by: rfeio |
last post by:
Hi!
I have a table with several rows, some of which I need to duplicate.
The fields of table1 are field1, field2, field3 and field4. Field1 is automatically incremented,
field2 will serve as a...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |