User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: SQL - questions .

  #11  
Dec 11th, 2007
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.
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*
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: SQL - questions .

  #12  
Dec 11th, 2007
Originally Posted by techna View Post
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*
Reply With Quote  
Join Date: Aug 2007
Posts: 1
Reputation: joelzeal is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
joelzeal joelzeal is offline Offline
Newbie Poster

Question Re: SQL - questions .

  #13  
Dec 18th, 2007
Hi am zeal,
Can anybody please explain to me what GROUP BY in SQL really does?
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: SQL - questions .

  #14  
Dec 18th, 2007
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. select avg(student_marks) from table group by subject
This 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*
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MySQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 11:12 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC