Problem in retrieving data from two table when one column entry in each table are same but no column in these table match with each other

Hello there!,

      First of all i have two tables . one acts as a master table and other one acts as a details table. Currently the ptoblem with my procedure is,

i have entered two entries for one project in the Master table. and to briefly discribe those two entries in the master table , i have entered two entries in the Details table corresponding to the entries in the master table.

Now i need to combine the master table entries and the details table entries for the same project which should give only two entreies. but my procedure gives four entries.

Could you please tell me a solution

Columns in first table,

SYS_Project_Name,

SYS_Actual_Start_date,

SYS_Actual_End_dat

Columns in 2nd table

CON_Project_Name,

CON_Plan_Start_date,

CON_Plan_End_date,


All I need is to retrive data from these two table where Project_Name in two Tables will have equal entries but column name only changes.

Currently My Code is,


CREATE PROC RET_PROJECT_INFO                          
@SYS_PROJECT_NAME     VARCHAR(10)                         
AS                         
BEGIN                         
SELECT   distinct                          
a.SYS_ACTUAL_SDATE,         
a.SYS_ACTUAL_EDATE,         
b.CON_PLAN_SDATE,         
b.CON_PLAN_EDATE         
FROM  SYS_PROJECT_DETAILS a,CON_PROJECT_DETAILS b                          
WHERE  a.SYS_PROJECT_NAME =@SYS_PROJECT_NAME and b.CON_PROJECT_NAME =@SYS_PROJECT_NAME
END

Thanks In Advance,


Much Obliged & Thanks a Lot,
Myself
0
Sidewinder2
8/26/2008 11:57:40 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

4 Replies
1046 Views

Similar Articles

[PageSpeed] 24

 

CREATE PROC RET_PROJECT_INFO                           
@SYS_PROJECT_NAME     VARCHAR(10)                          
AS                          
BEGIN                          
SELECT   distinct                           
a.SYS_ACTUAL_SDATE,          
a.SYS_ACTUAL_EDATE,          
b.CON_PLAN_SDATE,          
b.CON_PLAN_EDATE          
FROM  SYS_PROJECT_DETAILS a,CON_PROJECT_DETAILS b                           
WHERE a.SYS_ProjectName = b.SYS_ProjectName and a.SYS_PROJECT_NAME =@SYS_PROJECT_NAME and b.CON_PROJECT_NAME =@SYS_PROJECT_NAME

END 

(or)

CREATE PROC RET_PROJECT_INFO                           
@SYS_PROJECT_NAME     VARCHAR(10)                          
AS                          
BEGIN                          
SELECT   distinct                           
a.SYS_ACTUAL_SDATE,          
a.SYS_ACTUAL_EDATE,          
b.CON_PLAN_SDATE,          
b.CON_PLAN_EDATE          
FROM  SYS_PROJECT_DETAILS a
inenr join CON_PROJECT_DETAILS b on a.SYS_ProjectName = b.SYS_ProjectName 
where a.SYS_PROJECT_NAME =@SYS_PROJECT_NAME and b.CON_PROJECT_NAME =@SYS_PROJECT_NAME
END 
 
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
0
ramireddyindia
8/26/2008 12:19:09 PM

Thanks For Ur Reply

 

But it gives the same value

 For example in CON_PROJECT_DETAILS

i have entries like this

CON_PROJECT_NAME 
CON_PLAN_SDATE
CON_PLAN_EDATE          
     
ERP 08/20/2008 08/25/2008

 

 

But i am getting

In SYS_PROJECT_DETAILS

SYS_PROJECT_NAME 
SYS_ACTUAL_SDATE
SYS_ACTUAL_EDATE
     
ERP 08/25/2008 08/27/2008

 

then the result should like the following

 

PROJECT_NAME 
CON_PLAN_SDATE
CON_PLAN_EDATE          
SYS_ACTUAL_SDATE
SYS_ACTUAL_EDATE
         
ERP 08/20/2008 08/25/2008 08/25/2008 08/27/2008

But i am getting the result as

PROJECT_NAME 
CON_PLAN_SDATE
CON_PLAN_EDATE          
SYS_ACTUAL_SDATE
SYS_ACTUAL_EDATE
         
ERP 08/20/2008 08/25/2008 08/25/2008 08/27/2008
ERP 08/20/2008 08/25/2008 08/25/2008 08/27/2008


Much Obliged & Thanks a Lot,
Myself
0
Sidewinder2
8/26/2008 1:08:35 PM

 

select  <your required fields>  from CON_PROJECT_DETAILS  CP

inner join SYS_PROJECT_DETAILS SP on SP.SYS_PROJECT_NAME = CP.CON_PROJECT_NAME 

actaully the above query enough. if still it giving duplicate results. place distinct keyword

select  distinct <your required fields>  from CON_PROJECT_DETAILS  CP

inner join SYS_PROJECT_DETAILS SP on SP.SYS_PROJECT_NAME = CP.CON_PROJECT_NAME 


Give a man a fish and you feed him for a day. Teach a man to fish and you feed him forever.
0
ramireddyindia
8/26/2008 1:14:37 PM

Thanks For Ur reply!


Much Obliged & Thanks a Lot,
Myself
0
Sidewinder2
8/26/2008 1:26:35 PM
Reply:

Similar Artilces:

populating a column in one table with data in a column from another table?
Hi,I have one main table and multiple smaller tables, the main table consists of all the information gathered from the smaller tables, plus some other data. I've set primary keys for all the smaller tables and created a relationship where the primary key id matches an id field inside the main table eg. there's a smalltableid column in both the smaller table and the main table.some misc info:i'm using a dataset (should the key in the dataset be pointing to the main table, or the smaller one?)both relation and foreign key constraints are created (with no rules set)my problem is, the data from ...

Problem with comparing a Table View Column with the Table Column?
I have a CVdetails table which all the personal and technical details along with the path called CV_Path which stores the path of CV word doc. Using Index Server Query i got the paths in my SQL server using Linked Server. I used this Query   SELECT Path FROM OPENQUERY (FileSystem,'SELECT Directory, FileName, DocAuthor, Size, Create, Write, Path FROM SCOPE ('' "c:\myCatalogFolder" '') WHERE FREETEXT (‘’reference’’)’) Which gave a result as   Path c:\mycatalogfolder\ajaxguide.doc c:\mycatalogfolder\quickguide.txt     Now,...

Retrieve Data from two tables columns in one DataList Control!!!
 Hi, There is a DataList Control to retrive Data from Database Table.I want to retrieve data from two tables columns in one DataList. How can i? Thanks in Advance  Asghar Ali Mohammed http://www.aliwebdev.com(Web Designer and Developer)Do not forget to "MARK AS ANSWER" on the post that helped you.  Can you give an example of what you want to achieve?Regards,PrashantDont forget to click "Mark as Answer" on the post that helped you. Hii...SqlConnection myConnection = new SqlConnection("Your connectionString");SqlDataAdapter ad = ne...

No table index exists or at least one table index column is not included in data source. Data can be displayed but not updated.
No table index exists or at least one table index column is not included in data source. Data can be displayed but not updated. I get this error when trying to build a form, i'm connected to a remote database, the DBA states I have permissions on the tables i'm working with. There is no index on these table, all columns in table are being included in form i get this error. Been unable to find any info on this error in user documentation. Thanks in advance. Melissa Johnson Forms require that there is a unique index / primary key on a table. If neither of those exis...

Problem in using sqlbulkcopy to insert data from datatable(no identity column) into sql server table having identity column
Hi, I am having problem in bulk update of a sql server table haning identity column from a datatable( has no identity column) using sqlbulkcopy. I tried several approaches, but it does not show any error nor is the table getting updated. But the identity value seems to getting increased every time. thanks. varun Hmmmm...that means it is inserting something...I wonder if your datatable has data in it. Can you check that?Thanks,MaxLet Me Google That For You! The first thing i did was checked it. The datatable is getting populated fine. What could possibly be wrong si...

tables? how many table should i use for one data.mdf ? 150 tables? is it a problem ? or they run good ?
hello friends tables? how many table should i use for one data.mdf ? 150 tables? is it a problem ? or they run good ? per table can has 40 almost coulumname cheersMark as me if my question or my answer can be helpful for you :) oguzkaygun:tables? how many table should i use for one data.mdf ? It all depends on your application and its requirements, but as much as you need to get it done correctly, taking into consideration normalisation and other database design principles. oguzkaygun:150 tables? is it a problem ? or they run good ? per table can has 40 almost coulumname No...

SQL Server Table's column Referencing two parent tables.
Hi everybody,  I know that it is possible for one column to reference two different parent tables by defining two foreign keys on a same column, I have done it and SQL Server does give any error. But I want to know that is it advisable to define multiple foreign key on a column referncing two differnt parent table's primary key in differnt case... ? Means If Case 1 then It should reference to column1 or table1 otherwise it should reference to table2? How is it practicle...?    Please, 'Mark as Answer' if this post has helped you! - Bihag Thakerhttp://bihagt...

two db table column, one datagrid column
Dear all, I have a db table which have two column, first name and last name. Can I show them in one datagrid column? Thanks Yes you may. Through the usage of the TemplateColumn, yes. An example of this: <code> <asp:DataGrid runat="server" ID="dgSomeGrid">     <Columns>         <asp:TemplateColumn>             <ItemTemplate>                 <%# DataBinder.Eval(Container.DataSource, "LastName") %&g...

insert multiple values from one table into one column from another table?
Hi, I'm attempting to create an insert statement that gets the values from multiple columns and insert them into one column from another table, is there a simple solution to do this?Here is something similar to what i'm wanting done, just it's not the correct way to do it, i want value1, value2 and value3 from one table to be combined and put into the value1 column of another table, what am i doing wrong? INSERT INTO tablename2 (value1 + value2 + value3)SELECT value1FROM tablename1 thanks in advance! INSERT INTO tablename2 (SELECT val1 + val2 + val3 FROM tabl...

copy column from one table to another table
Hi, I have 2 tables. Table1 has column1 and column2. I wish to copy column1 into Table2 by using sql statement. How do i do that? Thank you. In general you'd do it like this: Insert statement: INSERT INTO Table2 ( Column1 ) SELECT Column1 FROM Table1 Update statement: UPDATE Table2 SET Column1 = T1.Column1 FROM Table2 T2 INNER JOIN Table1 T1 ON T2.someID = T1.someID TerriTerri MortonEngagement Manager, NeudesicHow to ask a question...

is there an sql statement to insert data to one table and getting the data from another table
Ok I have a table that have general categories with just name and CatNo. Now what I want to know is when I create a client to move all the data in general categories to another table called categories that have the clientid to associate it with the client. I would appreciate for any help what is your question here??Shravan Addaypally MCP...

Display multiple columns in Gridview from One Column of SQL table
Hi I have a table in sql with 2 columns and I want to display that in multiple columns in Gridview. SQL Table No.            Type 1               A1 1               B2 2              A2 2               B2 3        &...

Exporting in Excel without cells or excel columns merging for one column of data table(need sorting, data filters perfectly)
 Hi,   I have an issue with the excel exporting of the report using ssrs.  I am using only the body section for exporting to excel.  Here in the body i have an Image, Textbox(for Title), textbox2(for dates from,to) and below it i have a table having the columns used for showing the data.  The report gets generated but when i exported to excel, All the columns and rows in the excels sheets come close and its like there is no uniformity.  Few columsn of excel are covered under a single columsn of the data table.  So its making users feel uncomfortab...

Data Access Layer : Fail to read data from two table by one Table Adapter
I have an Access Data Source containing a few tables.I want to set up a DAL for data access and I add a dataset to my projectHowever, when I added two table into a table adapter, VS can't read any data from the data source (while the connection is successful as the columns and rows are loaded)  The two tables are called bidding and itemHere is the SQL generated:SELECT      item.itemId, item.shortTitle, item.picture, item.durationHour,                     ...

Web resources about - Problem in retrieving data from two table when one column entry in each table are same but no column in these table match with each other - asp.net.sql-datasource

Mother of three killed landlord after he tried to stop her retrieving her son's shirt
A mother of three has been found guilty of killing her landlord after he tried to stop her retrieving a red polo shirt her son needed for school ...

Retrieving bodies a 'horrifying' experience (01:43)
Anti-jump measures on the Story Bridge should be "fast tracked" and water police funding increased so CityCats don't have to pick up bodies. ...

Man drowns retrieving toy boat
A man has drowned after entering the Wimmera River at Horsham to retrieve a remote-controlled boat.

Bishop says there is no time limit on retrieving MH17 remains
THE Australian Federal Police have warned that it is too dangerous to approach the MH17 crash site in war-torn eastern Ukraine until security ...

Search underway for man swept away in Brisbane River while retrieving toy boat
A search is underway for a man swept away in the Brisbane River while retrieving a toy boat.

DPRK blames US for suspension of retrieving American soldiers' remains
DPRK blames US for suspension of retrieving American soldiers' remains People's Daily Online PYONGYANG, Oct. 13 The Democratic People's Republic ...

Good dog: Yankee retrieving a big Canada in a Manitoba hayfield
Good dog: Yankee retrieving a big Canada in a Manitoba hayfield

iPhone dev: Retrieving user phone numbers
... a secret to recovering user phone numbers that does not involve the … One of the most common questions I get these days has to do with retrieving ...

Girl stuck in Dover storm drain retrieving phone
A teenage girl gets stuck in a storm drain in Dover while trying to retrieve her mobile phone which had fallen into it.

Forensic investigations: Retrieving data from the cloud
... ensure that nothing is missed in the evidence gathering process, and to ensure that the investigative team doesn’t run out of time when retrieving ...

Resources last updated: 12/11/2015 12:09:22 PM