Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Delete Duplicates But Keep 1?


I need a way to delete from friend_bulletin WHERE user_id AND subject have duplicates

example

user_id subject
1 test
2 test
1 test
4 dfgdf
5 dsgdsf
1 test

In the axample there are 3 duplicates 1 - test

I would like a way to do this but keep 1 of the duplicates




View Complete Forum Thread with Replies

Related Forum Messages:
Delete Duplicates In MySQL
I have a database in MySql which has 2 fields. The 1st field is called id which is the primary key. The 2nd field is called full_add where there are some duplicates.

I would like to delete all the duplicates in the full_add field leaving only 1 record behind.

It does not matter if the corresponding primary key gets deleted as well because the primary key is not related to any other table or database. I prefer not to use temporary tables or create new tables because my webhost does not allocate much memory to me & my database is quite big.

View Replies !
Delete Record - When The Delete Link Is Clicked The Next Page Is Blank And Nothing Is Deleted.
This is my "delete.php" and this "todo/delete.php?id=64" an example of a link to it generated from the index.php page. When the delete link is clicked the next page is blank and nothing is deleted. What have I done wrong?

<?
include("dbinfo.inc.php");

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$id="delete from todo where id='$id'";
mysql_query($id);

mysql_close();
?>

View Replies !
Duplicates
check for duplicates of anything? For example, in the customers table, I want to check for duplicate zip codes, and display them. So, if there are 40 records of zipcode ?', and 35 records of? By the way, I don't know what zip codes are out there, I just used those as examples. So, I don't have an particular zip code I'd like to view. I'm just curious to see how many of any duplicate zip codes are in the table.This query does the exact opposite of what I want to do:PHP Code:

SELECT DISTINCT zipcode FROM customers And I tried this query,but it only seemed to cause my PhpMyAdmin to bog down:PHP Code:

SELECT zipcode FROM customers
WHERE zipcode IN
       ( SELECT zipcode FROM customers GROUP BY zipcode HAVING COUNT(*) > 1 )

How would I pull out only zip codes, if, there are more than 1?

View Replies !
Mysql Delete - $query = Mysql_query("DELETE
how would i do the following ?

$query = mysql_query("DELETE notes, datestamp, abs_value, ID FROM absence_mgt  WHERE datestamp='$date' AND ID='$vtc_login' ") or die(mysql_error());
im just getting "Unknown table 'notes' in MULTI DELETE" ?

View Replies !
Code To Look For Duplicates
I would like to create a php script that would search a log file and spit out the top 10 requested songs but...only allow an IP to vote for the same artist once. So for example. The log file looks like this.

04-03-2002,18:40:40,xx.xx.xx.xx,0,Brett Raymond - Angel's Gonna Find You.mp3
04-03-2002,19:33:20,xx.xxx.xxx.xx,0,Alex Mackey - I Know That My Redeemer Lives.mp3
04-03-2002,19:43:21,xx.xxx.xx.x,0,F:Jenee Wright - His Eye Is On The Sparrow.mp3
04-03-2002,19:45:44,xx.xx.xx.xxx,0,Jeff Long - Gethsemane.mp3

The xxx's are the IP's which I masked for this example. Is PHP capable of doing what I need or should I look into a Delphi or C++ program? If PHP can do this how would I start it out?

View Replies !
Removing Duplicates
I'm getting some data from a database, but there are duplicates for every entry. For instance, if you looked a table of posts for this forum, you'd see posts and the author.  I'm getting the author, so there could be hundreds or more of repeats. I'd like to basically get all the uniques in a column. 

View Replies !
Sql Counting Duplicates
Hy

I have this code:
------------------------------------------------------------------------
$result = mysql_query("select * from smjestaj left join grad on
grad.grad=smjestaj.grad_pbroj order by grad_pbroj ASC", $db) or die ("Could
not read data because ".mysql_error());


// print the data in a table
if (mysql_num_rows($result)) {

print "<table cellspacing=0 border=1 width="25%" class="redovi">
";
print "<tr class="headline"><td> Grad </td></tr>";
while ($qry = mysql_fetch_array($result)) {
print "<tr><td><a href="" .
"lista_sa_linkovima_po_gradovima.php?grad=$qry[grad_pbroj]"[color=blue]
>$qry[Naziv]</a></td>";[/color]
print "</tr>
";
}
print "</table>
";
}
mysql_close($db);

------------------------------------------------------------------------
Table smjestaj has coloumns:
id | Name | grad_pbroj | ...

Table grad has coloumns:
grad_pbroj | Naziv|

Now i wanna display all the grad_pbroj coloumns from 'smjestaj', buth not
displaying duplicates, just to count them, and put the count behind the
'grad_pbroj' coloumn.

Result:
Naziv_first (3)
Naziv_second (1)
Naziv_third (8)

I nead full solution, because i have tried everythig and either sql of php
displaying is fucking me.
I have tried all of that group by, count sql syntax, and i allways get
error.
Anyone cann help me plz.
Dejan

ps. sorry to all the people i have asked this before, buth not giving full
description (Arjen, Jerry Stuckle).

View Replies !
Prevent Duplicates
I have a simple db with three columns,id name and details. There are two forms for adding and editing details, to be sure that the add details form does not create duplicates i need to:

check that a name does not already exist before the new data is inserted, if the name already exists then i want to simply update the details.

View Replies !
Getting Only Duplicates In Array
how is it possible to get only duplicates in arrays? Here's the example I want to work on and only want to get the data that are marked here with a * Code:

View Replies !
Check For Duplicates
i have a small problem of checking for duplicated unique data input. i want to know if its possible to write a php script which if i copy and paste an address book from one data source and save it, then update addresses from a different source it will say something along :- error $address already exists in this document. if so could someone point me in the right direction?

View Replies !
Remove Duplicates
I have the following:

$result = mysql_query("SELECT * FROM products ORDER BY CategoryID");

How do I modify that to get rid of the duplicates in CategoryID?

e.g. I dont want a list saying red, red, red, blue, blue, yellow, yellow.

Rather, I want it to show red, blue, yellow.

View Replies !
Find Duplicates
I want to have a php page which displays all the duplicate members in my database, I just want it to show in a table FirstName, LastName, The No. of Matches, And also have a clickable View link... Anyone done this before?

View Replies !
Preventing Duplicates
I'm doing something where I need to enter ID numbers, but I don't want the same one twice. Furthermore, I would like for the page to give an error if this happens.

I don't entirely know how to do this, but I've read around and found stuff like

mysql_query("SELECT COUNT(*) FROM <table> WHERE <column>"). This is great and all, but if I try to save that value to a variable, like

$counter=mysql_query("SELECT COUNT(*) FROM <table> WHERE <column>"),

I don't get a number, such as 0 or 1 or anything that I want, I get a Resource #3 or something along those lines. All I want is to be able to check the database against the ID given in a form to see if it is there. Code:

View Replies !
Trying To Avoid Duplicates
I am trying to run a select statement before an IF to avoid inserting duplicate records, as follows Code:

View Replies !
Duplicates Across All Fields
I ve been reading all the forum posts on finding duplicates and theyre generally on the first name last name basis.

I however need to find duplicates across the entire structure of a table. That is, every field (total 30) of a record is a duplicate entry of another record except the id field which is set to autoincrement.

View Replies !
Deleting Duplicates
I need to compare two arrays of strings and delete all the duplicates values from both arrays. Is this possible? The only related function I could find is array_unique() but even that doesn't seem to do what i need.

View Replies !
Want To Remove Duplicates In A String
I have one further question about improving a validation.
Currently this will validate a string of words separated by commas, and
if it's greater than 9 will do something, or something else if less
than 9. How can I improve this, so before it does the checking remove
any duplicates in the string?

<?
$tmp = explode(',',$your_str);
if (count($tmp) > 9) {
// do something

} else {

// do something else

}
?>

View Replies !
Checking For Duplicates In Database
how can i check for duplicates in a database. For instance, checking for already registered users, etc.

View Replies !
Duplicates Appart From 1 Field.
I have a table containing 4 columns. There are a number of duplicates that have the same data in 3 columns, the 4th column is time, which is always different.

The following 'nearly' works. The time field is obviously not included.
SELECT DISTINCT `ID`, `State`,`OptUser` FROM tblStatus ORDER BY ID DESC

If I add the time, all fields are returned as they are all different.

I need to remove the duplicates. It doesnt matter which date gets removed, preferably the latest one stays, but doesnt matter.

View Replies !
Remove Duplicates In An Array
Here is my array:

$myarray = "B12@A10@C11@C11@B12@F10@B12";


Is there a function I can use that will remove all duplicates and just keep 1 instance if there is a duplicate. So in the above example my new array would be:

$new_myarray = "B12@A10@C11@F10";

View Replies !
Loop Through CSV - NOT Inserting Duplicates
we have a script that opens a CSV loops through the file and inserts the contents into a DB. is there any way to ensure we dont INSERT duplicate records?

View Replies !
Removing Duplicates From A List Box
I have written a script, that pulls the cities and zip codes from a database and puts them in a list box, for people to select from. I have several duplicates in each. How can I remove the duplicates so that every city and zip code only displays once. Here is the code I am working with.

<?
@require_once('connectdb.php');
$select = "SELECT * FROM listings";
$result = mysql_query($select);
while($data = mysql_fetch_array($result)){
$city[]=$data[&#397;'];
$zip[]=$data[&#399;'];
}
?>
<form action="search.php" method="post" name="search">
<table>
<tr><td>
...

View Replies !
Query To Avoid Duplicates
$sql_ = mysql_query("SELECT * FROM category_table WHERE `group` <> ''");
while ($row = mysql_fetch_array($sql_)) {
   $group = $row['group'];   
   echo $group;
}

View Replies !
Remove Duplicates In Query
I'm querying 2 fields in 1 table. Both fields have got duplicate records. I want the end result to display in 1 temporary(temp) field with no duplicates. My code that does 90% of the work is below. The part that I don't know how to do is how to remove the duplicates from the temporary(temp) field? PHP Code:

SELECT DISTINCT ap_expiry as temp FROM developer1 UNION SELECT DISTINCT licence_expiry as temp FROM developer1 ORDER BY temp DESC

View Replies !
MySQL FT Search - Removing Duplicates
I have a MySQL Fulltext search engine that works beautifully. One problem though: If a row has more than one occurence of the search term, it will display the row over and over for each match. Is there a way that I can return only one row? I tried "array_unique" but I couldn't get it to work.

View Replies !
Trying To Prevent Duplicates In Preg_replace Regex
I'm trying to write a regex pattern to use in preg_replace. Basically
I want to put [brackets] around every line (
) in this variable.
However, I need to exclude lines that already have brackets or
quotation marks around them as well as lines that start with a
hyphen. Lastly the lines with ** need the brackets before the **,
instead of at the end of the line.

Here is what I have so far - it is close, but I keep ending up with
duplicate brackets.

$temp = 'this
is
a
test
"this"
"is"
"a"
[this]
[is]
[a]
test ** 93.23
test 2 ** 10.05
-this
-is
-a
another good test
'
$PATTERNS = array("/^[^"[]/m", "/[^"]]$/m", "/[
]+/", "/ **
(.*)]/");
$REPLACEMENTS = array("[", "]", "]
[", "] ** $1");
$output1 = trim(preg_replace($PATTERNS, $REPLACEMENTS, trim($temp)));
print_r($output1);



View Replies !
Is There An Easy Way To Purge All TRUE Duplicates?
I have a table with a lot of duplicate records... Is there an easy way to purge all TRUE duplicates? or do I need to write a script to do it?

View Replies !
Count Duplicates / Array Script
In table accounts_contacts, there are multiple contact_id's related to a given account_id, and I would like to count the reationships and assign the count(*) value to accounts.mao (multi agent office) Code:

View Replies !
Avoid Duplicates In MySQL Result Set
I have a database say for types of pop. So this is the db

Cola 1
Cola 2
Cola 3
Cola 1

all with unique id's. I would like to display the names of cola on the main page but I would not like duplicates displayed regardless of how many there are. So for the db i just displayed i would like the main page to look like this. Code:

View Replies !
How To Import Csv File And Check Duplicates
is there any sql code that can import csv file into your mysql db and at the same
time checked or send a report of the duplicate items? currently this is the query that i use for uploading csv file. Code:

View Replies !
Count Duplicates In A Text File
I have a script that write log id number to a text file. I have written a script to read the data line by line. What I need to accomplish is to count the number of time the id is repeated. Example of data is listed below:

37775
35707
37450
28105
28105
35527
28223
28224
28372
28373
36730
38144
37581
36201
38154
22341
36834
36540
37992
31305
26570
31662
35743

View Replies !
Query MySql Database - Duplicates
I've got a field in a MySql database that I'd like to query. This field contains names of people & there are some duplicates as well. The end result of my query should look like this:-

HTML Code:
NAMENUMBER OF RECORDS
Jonh2 records
Alice4 records
Builder8 records
Yahoo5 records



View Replies !
Random Image Stop Duplicates
i am trying to create a homepage with random images and data displayed... e.g the items picture and price.... i have managed now to do this but i get duplicates how can i stop this.. Code:

View Replies !
Mass Mailer Sends Duplicates
I wrote a mass mailer program and am having problems with it sending duplciate emails to the same email address. Sometimes it will send as many as 4 or 5 emails to the same address. I am using the phpmailer class version 1.73. I also have it set up to use a POP3 account. I am going to be changing it so that I use either sendmail or qmail depending on the server I set it up on. I have tried writign the program several different ways to try to stop it from sending duplicates, but it still does.

When I run a test with 2 or 3 emails in the test table in the database it only sends one message to each email address, but when I send out to several hundred or more email addresses it sends multiple emails to each address. It sends to all the addresses in the query one row at a time, then it proceeds to send to all of them again.

View Replies !
Remove Duplicates And Loop After Explode()
I've used explode() to seperate a string of words into a whole bunch of substrings, and now need to manipulate them a bit beyond merely echoing them out one by one. Firstly, there will be duplicated substrings, how would I go about removing them? After removing any duplicates I then need to echo all the remaining substrings as a list on my page, how would I run a while loop on them to do this.

View Replies !
Need Help Putting Data Into Array / Removing Duplicates
I've got a variable that looks like:

31, 1, 1,1,1,1,164, 164,29, 29,29,29,37,2,2,2,2,2,2,
147,147,26,26,49, 138, 138,138,138,138,138,138,137, 137,168,
170, 170,48, 172, 44, 187, 183, 185, 195, 184, 186, 45, 46,
194, 167, 182, 181, 34, 18, 16, 25, 28, 53, 53,11, 11,10, 20,
192, 39, 54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,
54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,
54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,
54,54,54,54,54,58, 58,58,58,58,58,58,58,58,58,58,58,58,58,58,
58,58, 175, 176, 180, 177, 178, 179,


I'm sending it to a mysql query which will say NOT IN($variable 0) (the 0 is added because the variable ends with a comma). I'd like to remove the duplicates but have no idea how. I figured if I stick it in an array it will be easier. There is an array_unique function after all. But I have no idea how to get the data in an array. I tried $arr1 = str_split($variable); but it spit out an error, probably due to the trailing comma.

View Replies !
Checking For Duplicates In Database On Form Submit
I had the idea to use the following to check for duplicate value when a form is submitted to a database:

elseif ($result == $_POST['serialnumber']) {
         $db_handle = pg_connect('dbname=test2 user=andy password=da4531');
         $query = 'SELECT serialnumber FROM system';
         $result = pg_query($query);
         pg_close($db_handle);
       echo "<h2><b>Duplicate serial number!  Go back, change serial number and submit form again.<b></h2><br />";  }

I can't figure out how to get $_POST['serialnumber'] to check against each record of $result.  Any ideas?  All values of 'serialnumber' need to be unique.

View Replies !
MySQL Query - How To Select Names With Out Duplicates
I want to select names from a database
ie:
Dog
Dog
Dog
Cat
Bird
Bird

I want something where I can select >Dog, Cat, Bird instead of the three dogs and two birds. Can I do that?

View Replies !
Duplicates In A Dropdown Menu Populated From My Database
I've been searching to figure out how not to have duplicates in a dropdown menu populated from my database. This is what I have, but how do I change it to get rid of duplicates.

<?php
$result = mysql_query("SELECT City FROM residential order by City");
echo "<select MULTIPLE NAME="City_code">";
while($row = mysql_fetch_array($result)){

echo "<option name="City" value="$row[City]">$row[City]</option>";

}
?>
</select>

View Replies !
Duplicates Entrys That Do Not Have A Match When Joining The Customers Table
The below query duplicates entrys that do not have a match when joining the customers table. Why does this happen and how can I adjust this query.

SELECT *
FROM orders
LEFT JOIN customers ON customers.id = orders.customerid

WHERE orders.itemstatus = 'SHIPPED'
AND orders.location='".LOCATION."'

View Replies !
Form Validation - Finding Duplicates: Regular Expressions Or String Functions?
I'm trying to figure out the most efficient method for taking the
first character in a string (which will be a number), and use
it as a variable to check to see if the other numbers in the string
match that first number. I'm using this code for form validation of a
telephone number.

Previous records from the past few months show that when someone is
just messing around on one of our forms (to waste our time), they type
in a phone number like "555-555-5555" or "111-222-3333". Our Web forms
have three text boxes for each telephone number:

homephone1 = area code (3 digits)
homephone2 = prefix (3 digits)
homephone3 = suffix (4 digits)

businessphone1 = area code (3 digits)
businessphone2 = prefix (3 digits)
businessphone3 = suffix (4 digits)

My plan is to check for this pattern, then if I find it, just redirect
the user to the thank you page so they'll think the form was
processed, when it actually wasn't.

As we find additional patterns that people use for malicious data,
I'll enter those as well (e.g., 123-123-1234)

Also, if you see any tutorials, or articles that talk about "real
world" form validation please point me to them. I've been looking for
references for form-based validation logic that takes real world dummy
data into account, but haven't found much.

View Replies !
Delete From $var
Is it not possilbe to have a variable for the table name in a delete statement (mysql database). inside an if this button is hit statement I have:

$sql = "delete from $type where id_num='$number'";
mysql_query($sql);
echo "$sql";

when it echos $sql it doesnt have the $type var where the table name should be, it just leaves that blank.

View Replies !
Delete A Row
This should be simple enough but for some reason it's not working. The $name is a number which is being posted across when the user clicks submit. I want the PHP to then access the Database with this number and use it to delete the staff ID (which is a PK).

With this code I get the error:

Warning: ociparse(): supplied argument is not a valid OCI8-Connection resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 16

Warning: ociexecute(): supplied argument is not a valid OCI8-Statement resource in /homedir/ilex-s01/jmsuther/public_html/DeleteStaff.php on line 17
;

The code is:

$name = $_POST["staffnodelete"];
IF ($staffnodelete=="" )
{print "You selected $name - for deletion ";}

putenv("TNS_ADMIN=/u1/oracle/Products/shu10g/network/admin");
$con = OCILogon("username","password","10g");

$query = "DELETE FROM staff WHERE staffno = $name";
$query = $query_post [$name];
$stmt = ociparse($conn, $query);
ociexecute ($stmt);

View Replies !
How To Delete
how to delete mysql row at php with checkbox?

View Replies !
Not Able To Delete
I've written a script to display all records in a database table and allow the user to select a record for deletion by entering it's ID number into a form at the bottom of the page.

When they click on the Submit button, it refreshes the page & shows the entire record that they selected and it asks if they're sure that they want to delete it.

There's 2 radio buttons that that allow them to select either "Yes" or "No". Everything is working fine up to that point. Where I run into problems is that no matter whether they choose yes or no, the record does not get deleted.

View Replies !
Delete Row
I am having a little problem with the following row to delete a row from my table. This script works fine on my home testing server but as soon as I put it onto my main web server it does not work and gives me an SQL syntax error. PHP Code:

mysql_select_db($database, $connect);
$sql = "DELETE FROM prices WHERE id=$id";
mysql_query($sql) or die(mysql_error());

View Replies !
Row Delete
what i am trying to do is delete all rows except for the last 20 rows, anyone know how this can be done?

basically i am keeping track of profile views so i know what members lasts seen who... my questin is how do i delete all but that last 2o for each $Member?

View Replies !
Delete
In one part of a review site i am making it allows top level users to make reviews witch includes uploading a picture and then changing the name to [name of review].[whatever], also it allows people to edit the review and change the picture, how exactly would i go about getting rid of the old picture so that i dont have to do hours of clean up.

View Replies !
Delete From Dir....
I have a field named 'path' in my db that has the exact same number(path) as its counterpart folder under cart/zips.

So my path in my db might be &#65533;', and in cart/zips you'd have the folder 23423423. There is a corresponding session with each 'path' row. Based on the session, I want to retrieve the path name and delete its counterpart folder name (and all it's sub-files it may contain).

The delete_all_from_dir function below is deleting the whole zips folder when I only want it to delete the path folder below it and its contents. Code:

View Replies !
How To Delete Fields
I would delete with php, all record of a table mysql where the seven left chars of the field is equal to the data in input($seven_chars).

I have used the the belowe istrucrion but it do not work.how can I do?

mysql_query ("DELETE FROM my_table WHERE substr(myfield,0,7)=$seven_chars");

View Replies !
Delete A Line In PHP
What i want to do is to open a file read the file Select a particular line from the file and delete that line and close the file. How to do it in PHP.

View Replies !
Can't Delete Cookie
Right I am quite new to php but have managed to create a simple log in/log out thing with cookies. All was working fine and as expected until I added a new section of the site. The new section stores another cookie (latest message user has read) so that next time they visit the site it will highlight the 'new' messages.
However since adding this I can no longer log out.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved