C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Training   ASP.NET Web Hosting    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

Play Silverlight Games or Submit your Silverlight applications and earn 90% AdSense revenue.

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Forums » .NET » SQL Server »

Query to avoid repeated records


Posted Date: 01 Dec 2007      Posted By: Ram Kumar      Member Level: Silver     Points: 2   Responses: 2



hi,

I am having a query to retrieve the item details ,i want only distinct item to be displayed for one user but i am getting more than one item for a single user.please help me

my query syntax is


SELECT distinct member.ibay_user_id as UserName,buy_memberdetail_id,buy_member_id,buy.win_status,Privatelist_ind,member.feedback_score,buy.amount as Amount ,buy.auction_ind as auction_ind,memid.email_id as emailid,member.first_name as first_name ,member.last_name as last_name ,
buy.created_date as create_dt,buy.bid_quantity as bid_quantity, CONVERT(VARCHAR,member.created_dt,109) as StartDate,itemdetail.remove_item_ind ,win_quantity,buy.created_date as bidded_date
FROM tbl_buy_member_detail AS buy
INNER JOIN tbl_member AS member ON buy.buy_member_id=member.member_id
INNER JOIN tbl_address AS memid ON buy.buy_member_id=memid.member_id and (memid.address_type_id = 1 OR memid.address_type_id= 2)
inner join tbl_item as item on item.item_id=buy.item_id
INNER join tbl_item_detail as itemdetail on itemdetail.item_id = item.item_id
WHERE buy.item_id=298 and buy.auction_ind=1 and buy.retract_ind = 0 and buy.cancel_ind=0 and buy.win_status=0 and itemdetail.remove_item_ind=0
ORDER BY buy.amount DESC






Responses

Author: Mohammed Shadab    01 Dec 2007Member Level: BronzeRating:     Points: 2

Hi Ram,

I think their is problem in join so it is returningmore then one record for one user, i donot know table structure

From tbl_buy_member_detail AS buy
INNER JOIN tbl_member AS member ON buy.buy_member_id=member.member_id
INNER JOIN tbl_address AS memid ON buy.buy_member_id=memid.member_id and (memid.address_type_id = 1 OR memid.address_type_id= 2)
inner join tbl_item as item on item.item_id=buy.item_id
INNER join tbl_item_detail as itemdetail on itemdetail.item_id = item.item_id



Author: Suba Ganesh    29 Sep 2008Member Level: SilverRating:     Points: 0

use distinct Keyword for !using repeated records


Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : How to store result of a query in a variable
Previous : How to Pass column names dynamically to a query
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use