Databases :: How To Avoid Duplicates In Sql With Joins
I am developing web application using csharp and oracle as a database. I have a three tables where I am pulling from records. But when write sql using inner joins and Outer join the records are being duplicated. These tables are being using joined using three(3) fields That are making up a compound primary key. How can I join them using an sql such that there is no duplicated. I am not allowed to modify the structure of the table. primary keys are in board
the tables are as follows;
Table1|:
STU_YEAR VARCHAR2(4)
Stu_CUO VARCHAR2(5)
STU_DEC VARCHAR2(17)
STU_NBER VARCHAR2(13)
STU_NBER NUMBER
STU_CODE VARCHAR2(3)
STU_BTCOD VARCHAR2(2)
STU_BASE NUMBER(18,2)
STU_RATE
Table2:
STU_YEAR VARCHAR2(4)
Stu_CUO VARCHAR2(5)
STU_DEC VARCHAR2(17)
CUP_CODE VARCHAR2(3)
CUP_BT VARCHAR2(2)
table3:
STU_YEAR VARCHAR2(4)
Stu_CUO VARCHAR2(5)
STU_DEC VARCHAR2(17)
KPP_CNAME VARCHAR2(3)
KPP_BTNAME VARCHAR2(2)
[Code]....
View 3 Replies (Posted: Oct 22, 2009 04:35 PM)
Sponsored Links:
Related Forum Messages For ASP.NET category:
Web Forms :: How To Avoid Data Class Duplicates
I have several LINQ-auto-created data classes which are created using dragging and dropping database tables into the Visual Studio LINQ design pane. Also, in my project I have to manually create WCF data-contract classes. Each WCF contract class is for one LINQ-auto-created data classes; one to one. Is there some better way to reduce the efforts to this problem? e.g. inheritance or something else to create WCF datacontract class from existing LINQ-data class. Example: [code].....
Posted: Jan 07, 2010 01:45 PM
View 3 Replies!
View Related
DataSource Controls :: Can Pull A Top Record And Avoid Duplicates
I have location #s, date, time, the sales amount, and tax in a excel file. The system pulls sales numbers throughout the day from each store location and places the total sales and tax numbers along with the polling date into a file. So the most current date/time has the most upto date sales numbers at the time for that location number, but it also lists the older entries so mgmt can see how sales went during the day, and this is where my issue is, I don't need to see the old numbers from this generated file (atleast at this part of the program). What I would like to do is write a query that only selects the most recent sales numbers for each location. I will output this to a table in ASP.NET. The query I tried using the TOP 1 clause only gave me the very first row listed below. [code]....
Posted: Feb 03, 2010 05:14 PM
View 5 Replies!
View Related
Databases :: SQL Joins - Getting Duplicate Contact ID
This query should not fetch duplicate contactID(i.e Same ContactID).but when i execute the query i get duplicated ContactID.I know it is a problem with Joins. Could anyone tell me what is wrong with my Query, Here is my query select ContactTracking.Contact_ID FROM ContactTracking ContactTracking LEFT OUTER JOIN Issues Issues ON ContactTracking.Issue_ID = Issues.Issue_ID LEFT OUTER JOIN HRA hra ON hra.HcnID = ContactTracking.HcnID INNER JOIN HPS_COMMON.dbo.wrk_user wrk_User ON ContactTracking.UserID = wrk_User.id_User INNER JOIN HPS_COMMON.dbo.def_Usertype def_Usertype ON wrk_User.id_UserType = def_Usertype.id_UserType WHERE ContactTracking.contact_date>'10-jan-2009' AND ContactTracking.Call_end_time is not null AND Contact_ID in ('122734','122738') And here is the ContactId result i get, 122734 122734 122738 122738
Posted: Jun 24, 2010 06:04 AM
View 5 Replies!
View Related
Databases :: SQL JOINS (LEFT And RIGHT) - Duplicate Records
I am developing web application using csharp on visual studio 2008 and oracle is my database. I have done sql with LEFT OUTER JOIN but the left table has depulicated records. So when I run the sql there are duplicates records coming out. How can I ensure that records are not duplicated becuase I am just getting the references from the Left Table. the sql being used is below. SELECT PRODUCTNAME,ACTIVI,HTestP FROM TR_PRO LEFT OUTER JOIN HHCODE@scko_link ON Hol||tarfisrt = HSJJ WHERE YNUMBER=" + int.Parse(Request.QueryString["BER"].ToString()) + " ORDER BY YNUMBER
Posted: Jul 16, 2009 08:14 AM
View 4 Replies!
View Related
Forms Data Controls :: Can Avoid Duplicates On A Data Grid
I am developing web application using Csharp on Visual studio 2008.How can I avoid duplicates on a data grid? I am using one form with datagrid. When I run it while it is in one of the folders AB it is running without any problems and data grid is displaying correct records. However, when I get the same and put it on a different Folder AB1 on the same machine and web server (IIS) it is displaying duplicated records?
Posted: Jul 19, 2010 03:57 PM
View 5 Replies!
View Related
ADO.NET :: Linq To Sql - Possible Optional Joins?
Is it possible to do an optional join as follows?: private void OptionalJoin(string phrase) { from t in db.Table // (if phrase != string.Empty then) join t2 in db.Table2 on t.Id equals t2.Id select t } Although I'm aware that I can copy/paste this and move the conditional logic outside the query, the query is ~200 lines and there are 4 different optional joins I would like to incorporate, so it would get messy and be difficult to maintain. I'm looking for a clean, streamlined way to do this.
Posted: Nov 22, 2010 08:01 PM
View 2 Replies!
View Related
C# - Linq Sum Columns Including Joins?
I have two tables.[Table.Game] Columns are "PK_id" "username" and "couponID" [Table.Coupons] Columns are "PK_id" "CouponID" and "Points" The two columns "CouponID" are associated with eachother. Let say i have two rows with the user "harry" in [Table.Game] this person has two different couponID. In [Table.Coupons] this user "harry" has "CouponID" 1 and 2. Column "Points" have 10 and 20. To the question how do u sum this two different point values that have different "CouponIDs". This does work if i have only one "CouponId". But not when the user has 2 different CouponIDs. Values is 0 var points = (from p in linq.Coupons join g in linq.games on p.couponID equals g.couponID where g.username == username && g.couponID == p.couponID select (int)p.win).Sum();
Posted: Mar 10 at 20:37
View 2 Replies!
View Related
SQL Server :: Combine Inner Joins - Get A Field Value From The First Statement
I have a select statement. I need to get a field value from the first statement. GOAL: Below is what I am trying to accomplish - the code below is not correct - Please modify the statement with the correct SQL Syntax. I want to query a table and based on the results I want to set the "If THE Else"statement to query then table with diffent inner joins. SELECT * FROM CONTENTITEM CI INNER JOIN CONTENTCATEGORY CC ON CI.CATEGORYID = CC.CATEGORYID IF CI.FORMTYPE = 200 OR 300 SELECT * FROM CONTENTITEM CI INNER JOIN CONTENTCATEGORY CC ON CI.CATEGORYID = CC.CATEGORYID INNER JOIN CONTENTFORMFIELD CF ON CF.ITEMID = CI.ITEMID WHERE CI.ITEMID = @ITEMID ELSE SELECT * FROM CONTENTITEM CI INNER JOIN CONTENTCATEGORY CC ON CI.CATEGORYID = CC.CATEGORYID WHERE CI.ITEMID = @ITEMID
Posted: Sep 14, 2010 05:25 PM
View 10 Replies!
View Related
DataSource Controls :: Grouping With Joins In A LINQ?
Basically there are a few joins and I would like to group on one column in one table and like to get sum of amounts in that table and then the columns from the other tabes as well. I have follwoing SQL query: Select b. Title, SUM(a.Amount) FROM table1 a LEFT OUTER JOIN table2 b ON b.ID=a.ID Group by a.Project, b.Title
Posted: Dec 09, 2009 10:13 PM
View 5 Replies!
View Related
DataSource Controls :: How To Optimize Query With Multiple Inner Joins
I have one question regarding how to make the below mentioned type of query more optimized so that mine query perfomace can be increased. Select a.name1,a.address1,b.field3,c.field4,d.field6,e.field7 from a inner join b on a.id=b.id inner join c on c.id=b.id inner join d on d.id=c.id iner join e on e.id=d.id union all Select a1.name1,a1.address1,b1.field3,c.field4,d.field6,e.field7 from a1 inner join b1 on a1.id=b1.id inner join c on c.id=b1.id inner join d on d.id=c.id iner join e on e.id=d.id union all Select a2.name1,a2.address1,b2.field3,c.field4,d.field6,e.field7 from a2 inner join b2 on a2.id=b2.id inner join c on c.id=b2.id inner join d on d.id=c.id iner join e on e.id=d.id All the above three select query at last using the same inner join condition, means last two inner join condition are the same for all the select query. Is there any way so that this query can be optimized?
Posted: Mar 22, 2010 05:12 AM
View 2 Replies!
View Related
SQL Server :: Joins - Returns A Row When There Is Matching Table In Both Tables
Inner Join:- Returns a row when there is matching table in both tables. we can use comparison operator like =,<,>,<> I created two tables TableA ID OID Type 1 1 A 2 6 B 3 7 C 4 10 D TableB ID Value 1 10 2 30 3 40 5 60 6 70 Basic Inner Join select Type From TableB as a inner join TableA as b on a.ID=b.OID Result Type A B If i want only the type which has not match in tableB then i can use not in subquery i get the result if i m using select Type From TableB as a inner join TableA as b on a.ID<>b.OID then i get Type A A A A B B B B C C C C C D D D D D 18 rows affetected i m suprise
Posted: Jan 29, 2011 04:22 PM
View 3 Replies!
View Related
SQL Server :: Table Joins And Datasets To Bind The Gridview In Page
I have a web service with a dataset and I need to fill a gridview in my web page with data from multiple tables (like 4). How can I retrieve data from my 4 tables and construct a datatable with a table adapter in the dataset? I need to create this in the web service to bind the gridview in my page. In SQL I create a view with the joins of the 4 tables and added the view to the dataset. It works fine, but for other windows in my web page I need to use like 8 trough 10 tables (just to retrieve one field of each one) and I don't know if making that huge joins is the more efficient way to retrieve data from the server. There is another way to make joins? (Make separate queries for each table and create one table in memory) How?
Posted: Mar 25, 2011 06:29 PM
View 2 Replies!
View Related
DataSource Controls :: Sql Joins - Display All The Groupnames And The Corresponding Campaignname Column To Be Null
This is the query which iam working on : BEGIN select PKCampaignID,cm.FKUserID,CampaignName,CreatedBy,StartedOn,CompletedOn,fkgroupid into #tmpcampmast from CampaignMaster cm join (Select * from CampaignGroups cg join GroupMaster gm on cg.FKGroupID=gm.PKGroupID where gm.FKUserID=@inUserID)[tt] on cm.PKCampaignID=tt.FKCampaignID Select FKUserID, PKGroupID, GroupName, LeadCount=0, LeadsTouched=0, LeadsUntouched=0 into #tmpGroupLeadsSummary from GroupMaster where FKUserID =@inUserID select * from #tmpcampmast right outer join #tmpGroupLeadsSummary on #tmpcampmast.FKGroupID=#tmpGroupLeadsSummary.PKGroupID END Here iam trying to join these 2 tables(temp tables #tmpGroupLeadsSummary and #tmpcampmast) Iam getting result as: [URL] But for another value of @inUserID iam getting: [URL] here in the groupname column i want to display all the groupnames and the corresponding campaignname column to be null.
Posted: Dec 25, 2009 12:58 PM
View 1 Replies!
View Related
SQL Server :: Slow Running Query Based On Multiple Tables Using Joins
One of my peer wrote a query based on multiple tables using joins. One of the table is in a different database The query was taking much time 1. Create an SP 2. Create a temp table and copy all records from the external db 3. Avoid using Left Join as much as possible and use Inner Join 4. Create and use indexes 5. Remove tables/columns that are not necessary In this scenario, I would like to suggest to use Covering Index, but how can it be created for multiple tables and a temp table?
Posted: Nov 15, 2010 05:43 AM
View 3 Replies!
View Related
C# - SQL - Returning Duplicates From Join?
My SQL query joins on multiple tables, and because of this it is displaying multiple results. I know about SELECT DISTINCT, but one of the fields ('Account.Name') is occasionally different, so it treats this record as a new row. Here is my SQL: [code]....
Posted: Dec 17 10 at 10:31
View 1 Replies!
View Related
How To Remove Duplicates From A List In C#
I want to remove duplicates from this list: List<Dictionary<string, object>> val = new List<Dictionary<string, object>>(); It does not work if I apply Distinct() in this way: List<Dictionary<string, object>> result = val.Distinct().ToList<Dictionary<string, object>>() Update: Problem is now solved. I used the MySQL union command to read table from the database.
Posted: May 3 10 at 6:34
View 2 Replies!
View Related
Hit Insert Several Times And Got Duplicates?
I have a simple asp.net web forms page that does an insert to my sql server db. My server was running slow at the time and I pressed Insert button several times because I didn't think it took but it did all 3 times.So I have duplicates from that one interaction. How would I prevent this?
Posted: Dec 10 10 at 23:23
View 2 Replies!
View Related
SQL Server :: 2008 Views And Table Joins - Retrieve Data At Once When The Page Loads
I have a web page with a GridView and a table outside the gridview to display more information of the record when it is selected (like record details). I'm using data of five tables for this particularly window. I use one table of the five to bind the gridview the other tables are for the details, but I use like 1 or 2 fields of those tables. I'm binding the page with web services. I need some advice on which is the better way for doing this to make a faster web page. In sql server I made a view with the five tables (all the tables relations are working perfectly). In the web service I call the view; and in the web page I call the web service to bind the page. Everything is working. All I want to do is retrieve from the server all the necessary data only once when the page loads and bind the five tables data (like 18 fields total) in the gridview which I only show 12 fields the other 6 fields are hidden, those 6 are for the details which I get with jQuery (that's another topic). Bind everything only once and manage the data on client side. Everything is working perfectly. Here is my doubt. How are the maximum table joins I can make? To retrieve the data via web and not get a server time out error. Which is a better way to make a faster page? Make 2 views one for the gridview and one for the details and put each view in a web service; or make one view with all the table joins and one web service. Right now all is working but I have to make other pages that use different tables and joins and I don't know if the server gets me the time out error when the page is fully working.
Posted: Mar 21, 2011 12:36 AM
View 1 Replies!
View Related
DataSource Controls :: Getting The Duplicates In A Column?
I have a table named dups. There are 4 columns in the table. id, name, path, hash I want to return only the name, path, hash of each row where the hash field is the same. Example there are 100 rows but only two qualify the return would be. file1 c: 10909 file4 d: 10909 For some reason this seems to be a more difficult task than I though it would be.
Posted: Jan 01, 2010 02:30 PM
View 3 Replies!
View Related
SQL Server :: How To Union Two Queries Without Duplicates
I have a sql query that returns 4 columns CustName CustId CustZip CustPhone I have a second sql query that returns the following 5 columns CustName CustId CustZip CustEmail CustAddress Both queries, query different data tables in the database, but return columns that are common to both. How do I union the two queries(Assuming a union is needed) Which will result in no duplicates and an end result being the following output: CustName CustId CustZip CustPhone CustEmail CustAddress As you can see we want to not have duplicate values on output. So something like the following is not acceptable: Jeff Stamper 2222234 81224 498-300-2222 Jeff Stamper 2222234 81224 498-300-2222 js@jj.com 122 Mars Blvd Karen Bops 3322234 81666 498-300-2222 Karen Bops 3322234 81666 498-300-2222 kb@lpo.com 322 Jamer Road
Posted: Aug 27, 2010 03:58 PM
View 4 Replies!
View Related
Doing Group Duplicates In Generic List
i have these values in my generic list: Product Name ItemCount Additional Info Brioche & Jam 2 Almond Croissant 4 Mixed Salad(v) 20 No Onions Mixed Salad(v) 5 What i am trying to do is group the duplicates so now the list would look like this: Product Name ItemCount Additional Info Brioche & Jam 2 Almond Croissant 4 Mixed Salad(v) 25 No onions
Posted: May 25, 2010 04:14 PM
View 1 Replies!
View Related
Scan String For Duplicates And Keywords?
I'm new to ASP, but have some knowledge of other languages. I want remove duplicate words in a string and it would be great if there is a way to check which words really matter. These words could be used for a search function. Currently i use this script to check en remove duplicates, but i can't get it to work. [Code]....
Posted: Jan 15, 2008 02:36 PM
View 5 Replies!
View Related
Finding Duplicates In String And Display?
Let say I have a string like this Dim Mystring as String = "Dogs;cats;Dogs;apple;cars;dogs;cats" I want to only find the values that is in the string more then once....and then create a new string like Result Dim NEWstring as String = "Dogs;cats"
Posted: Aug 04, 2010 09:51 AM
View 9 Replies!
View Related
SQL Server :: Insert Date And No Duplicates
I am importing images names from a file into a database by using the code below. When I import the image names, I aslo want to add a date of "June 12, 2009" in the DATE column. Finally, I do not want to import any duplicates. Is there something I can change in this code to make that happen? declare @cmd varchar(1000) set @cmd = 'dir "D:imagesREVIVE" /b' if (object_id('ImageTable..tblimages') is not null) begin insert into tblimages (imgname) execute xp_cmdshell @cmd delete e from tblimages e where ISNULL(e.imgname, '') = '' select * from tblimages end else create table tblimages ([id] int identity(1,1), imgname varchar(1000)) insert into tblimages (imgname) execute xp_cmdshell @cmd delete e from tblimages e where ISNULL(e.imgname, '') = '' select * from tblimages
Posted: Oct 08, 2010 04:40 AM
View 7 Replies!
View Related
.net - CssClass Duplicates On An UpdatePanel Update?
I've got a simple user control in my ASP.NET Webforms project which inherits from the LinkButton. It's got a property to change the size, which just adds some predefined CSS classes to the control. Protected Overrides Sub CreateChildControls() Dim SizeClass As String = String.Empty If Size = SizeEnum.Large Then SizeClass = "large" [Code].... So when it renders the class property is something like class="button small". When this control is placed inside an update panel along with some other things, when the update panel updates the class property for every one of these controls becomes class=" button small button small button small button small button small button small button small button small button small button small button small button small button small"
Posted: Apr 20 10 at 16:07
View 1 Replies!
View Related
Databases :: How To Avoid Or Solve (ORA-00911:Invalid Character) And ORA - 00911: Invalid Character In Sql
I am developing a web application using csharp on visual studio 2003. Connecting to the oracle database. However, I have a problem when it comes to the select statement or Search sql that I am using to retrieve records from the database table.The table where I am reading the information is as has records with details that have comas, slashes, characters like( <,>, &, %). But I have have no right to change the details in database table. But just to read from the table. The table has two fields namely Code, Codedescription.The sample of table record is as follows; Code Codedescription 1 Loctose and lactose syrup cont .By weigh <99% Lact 2 Frozen Sothern bluetin tuna (Thnnus maccoyii) 3 Textured yarn, nes, nprs 4 UNBLEACHED plain cotton WEAVE, WITH >= 85% COTTON 5 T/MOMTRS/PYROmtrs, not COMB, WITH OTHERS INSTRS Now the sql statement has to get the code by searching using the Codedescription details. But when the description with following characters( // <,>, &, %). is used to search Iam receiving the following errors. 1 (ORA-00911:Invalid character) 2 ORA - 00911: Invalid character How can avoid these errors? Second I can write an sql that will execute with characters( // <,>, &, %) in it, but with out giving errors. When I remove characters in Codedescription at the time of searching, it fails to pick the correct code. How can I solve this? Part of the code Iam using is below. SELECT Code FROM Matasttable WHERE STU_DSC = '"+ drpdescription.SelectedValue.ToString() +"';
Posted: Jun 10, 2009 03:33 PM
View 3 Replies!
View Related
|