•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 427,215 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,174 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser: Programming Forums
Views: 1236 | Replies: 13
![]() |
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
Oh, btw, if you have any duplicate rows, *I dont think it is possible to delete only the duplicate rows. You have to manually (
) delete them. *
Edit: The only way i can think of is, create a dummy table(new_table). Copy distinct rows from old_table to new_table. Truncate old_table. Copy the records from new_table to old_table. I cant think of ANY query to delete duplicate records from a table.
) delete them. *Edit: The only way i can think of is, create a dummy table(new_table). Copy distinct rows from old_table to new_table. Truncate old_table. Copy the records from new_table to old_table. I cant think of ANY query to delete duplicate records from a table.
Last edited by nav33n : Dec 11th, 2007 at 7:27 am. Reason: Added more..
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
•
•
•
•
To avoid duplication in column(s) we can create it with unique costraint. Constraint is nothing but rules that you can impose on the columns to be unique or not null etc. To create a unique column you can have the codes like:
create table mytable(col1 datatype unique, col2 datatype,...)
Or declare it as a primary key. Primary key is a combination of both "not null" and "unique" constraints.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
For aggregate functions like SUM, AVG, MIN, MAX etc, you should use group by clause. Group by clause groups the records depending upon the table field you mention. Say, for eg, you have a table. This table has 2 columns, student_marks and subject. You want to know the average marks of each subject. You can do this using the group by clause.
This will calculate the average marks of each subject and shows the average marks for each subject.
Cheers,
Nav
select avg(student_marks) from table group by subjectThis will calculate the average marks of each subject and shows the average marks for each subject.
Cheers,
Nav
Last edited by nav33n : Dec 18th, 2007 at 7:16 am.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ajax asp database decimal seperator thousand seperator when using sql server deleting records from ms sql table where columns have duplicate values developer development hacker management studio 2005 microsoft msdn news office security software sql sql cache dependency with polling-based invalidation survey vista
- Basic SQL made Hard (MS SQL)
- Simple sql questions (broken commands and retrieving columns) (Database Design)
- 2 Questions: license Installation and Speed (MS SQL)
- SQL Server vs MYSQL vs MSQL (i'm stopping now) (MS SQL)
- SQL server error: 18452 - connection to SQL error (Windows NT / 2000 / XP / 2003)
- ASP and SQL ? (MS SQL)
- 2 ASP Questions (ASP.NET)
Other Threads in the MySQL Forum
- Previous Thread: Favorite 3rd party software with MySQL
- Next Thread: Query Help



Linear Mode