Click here to Skip to main content
15,908,264 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
I have two different tables both having a common field i.e, Marriage Anniversary date and obviously of 'date' type. One is having details of husband and another having details of wife.
Is there any way, so that the upcoming Anniversaries may be fetched from both tables at same time or in same GridView(in Asp.Net)...
Or some other ways whatever I can do in this....
Posted
Comments
xszaboj 3-Dec-15 8:04am    
can you give more specific example of your table? and what you want? I might be able to help
Member 12133159 4-Dec-15 0:04am    
I'm having two tables having information of Marriage Anniversary Dates and other data of some couples. Now I have to fetch upcoming Anniversaries from both tables simultaneously so that I can display the name of couples with their Date of Marriage Anniversaries...
Suvendu Shekhar Giri 3-Dec-15 8:09am    
Just use JOIN
http://www.w3schools.com/sql/sql_join.asp[^]

And if you find issue while writing this query, come up with the problematic query so that we can help :)
CPallini 3-Dec-15 8:23am    
My (virtua) 5.
Suvendu Shekhar Giri 3-Dec-15 9:13am    
Thanks :)

1 solution

The issue here might be related to the fact that both tables has the same field names.

So you could use aliasing, something like:

C#
SELECT
  TableA.AnniversaryDate as 'TableADate',
  TableB.AnniversaryDate as 'TableBDate',
FROM
  TableA join TableB on (TableA.Key = TableB.Key)
 
Share this answer
 
Comments
Maciej Los 3-Dec-15 16:16pm    
Looks like MS Access database query statement...

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