User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Database Design section within the Web Development category of DaniWeb, a massive community of 392,009 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 4,232 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 Database Design advertiser:
Views: 966 | Replies: 6
Reply
Join Date: Dec 2007
Posts: 2
Reputation: atiti.m001 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
atiti.m001 atiti.m001 is offline Offline
Newbie Poster

Problems and Solutions in Database design

  #1  
Dec 10th, 2007
Hii guys, Here v can discuss about Problems in database design. If u know the answers , plese post ur answers here.
How do u get the distinct rows in a table/resultset?
How do u get the distinct rows without using the keyword DISTINCT?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 2
Reputation: anusri555 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
anusri555 anusri555 is offline Offline
Newbie Poster

Re: Problems and Solutions in Database design

  #2  
Dec 10th, 2007
By using the DISTINCT keyword,this can be achieved.The following example selects the distinct names from the employee table.
SELECT DISTINCT lname FROM employee.

By using the GROUP BY keyword,this can be achieved.The following example selects the distict names in the employee table,without using the DISTINCT keyword.
SELECT lname FROM employee GROUP BY lname.
Last edited by anusri555 : Dec 10th, 2007 at 11:47 am. Reason: spelling mistakes
Reply With Quote  
Join Date: Dec 2007
Posts: 7
Reputation: jsmith9990 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jsmith9990 jsmith9990 is offline Offline
Newbie Poster

Re: Problems and Solutions in Database design

  #3  
Dec 11th, 2007
Hey guys,
Me too have one doubt regarding database.

How can we insert a values in multiple rows using one insert statement ?
Please show one example.
Reply With Quote  
Join Date: Dec 2007
Posts: 7
Reputation: jimm00.kl is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jimm00.kl jimm00.kl is offline Offline
Newbie Poster

Re: Problems and Solutions in Database design

  #4  
Dec 11th, 2007
Haii..
The answer is,
INSERT INTO table
select('value1','Cina')
UNION ALL
select('value2','Dina')
UNION ALL
select('value3','Tina')

Thank you..
Reply With Quote  
Join Date: Dec 2007
Posts: 8
Reputation: tom3965 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tom3965 tom3965 is offline Offline
Newbie Poster

Re: Problems and Solutions in Database design

  #5  
Dec 11th, 2007
Hieo frnds...
Please help me out for finding the answer for this problem.

How can we get the duplicate rows from the table listed below using a single query.??

field1 field2 field3

1 2 3
2 4 5
2 4 5
3 4 3
1 2 3
Last edited by tom3965 : Dec 11th, 2007 at 6:40 am.
Reply With Quote  
Join Date: Dec 2007
Posts: 8
Reputation: tom3965 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tom3965 tom3965 is offline Offline
Newbie Poster

Re: Problems and Solutions in Database design

  #6  
Dec 11th, 2007
Hii frnds..
CREATE INDEX myIndex ON myTable(myColumn). What type of index will get created after executing the above statement? Why ?

and How can we swap values between two rows in a table using single sql statement?
show some examples also..
Reply With Quote  
Join Date: Jan 2008
Posts: 2
Reputation: subnet0 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
subnet0's Avatar
subnet0 subnet0 is offline Offline
Newbie Poster

Re: Problems and Solutions in Database design

  #7  
Jan 7th, 2008
Originally Posted by tom3965 View Post
Hieo frnds...
Please help me out for finding the answer for this problem.

How can we get the duplicate rows from the table listed below using a single query.??

field1 field2 field3

1 2 3
2 4 5
2 4 5
3 4 3
1 2 3



1> select *,count(*) as instances from DUPS group by field1,field2,field3
2> go
field1 field2 field3 instances
----------- ----------- ----------- -----------
1 2 3 2
2 4 5 2
3 4 3 1
Reply With Quote  
Reply

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

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

 

DaniWeb Database Design Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Database Design Forum

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