Click here to Skip to main content
15,867,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have a a database with two tables(RegFee_tbl and User_tbl),my RegFee_tbl have this columns:
ID,NumberPhone,ExpTime,RegTime,Fee,Transaction.
and my User_tbl have this columns:
ID,NumberPhone,Name.
now i using this Query to joining table together:

var st = (from s in db.RegFee_Tbl
                     join o in db.User_Tbl on s.NumberPhone equals o.NumberPhone
                     where s.ExpTime < DateTime.Now
                     select new { s.ID, s.RegTime, s.NumberPhone, o.FatherName, o.Name, s.ExpTime, s.Transaction, s.Fee }).ToList();

and i passing this "st" var to my datagride Source and everything is fine,but i have a problem, i getting rows in datagrid with the same Name e.g:
row 1 : Alex|123| and another columns data ...
row 2 : Alex|321| and another columns data ...
i want just get the one row with the same name(the final writed row in database if it's possible)

What I have tried:

i using select TOP query and searching so much but i dont find solution :(
Posted
Updated 9-Feb-23 11:13am
Comments
PIEBALDconsult 9-Feb-23 17:29pm    
"final writed row in database" -- generally not possible. Unless you store the insert and/or update timestamp in the record.

1 solution

We can't help you fix that: we have no idea which of the two (or more) records are the "correct" one - and that's probably important.

You need to look at your data - and start by asking yourself why you have the same data stored in two different tables at all ... redundant data is a bad idea, it leads to mistakes and errors which can be a nightmare to sort out when they are finally noticed.
 
Share this answer
 
Comments
Max Speed 2022 9-Feb-23 18:44pm    
@OriginalGriff yeah my tables have very anomaly issue :(
OriginalGriff 10-Feb-23 2:19am    
You are going to have to look at the whole DB design in the light of what you are storing, where, and why. Sorry - but there is nothing we can do to help you with that! :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900