Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi friends i need some helps
In my project(asp.net) sqlserver 2005 is backend in this i need query for retrive data from multiple table
for eg
table1:traindetail(tid(p.key),name,source,destination,date)
table2:class(tid(f.key),class,seat)
i have one form in i collect users input like source,destination,class,date
when user submit then it check the two tables and it match then display conformation message
how can i get it
Posted
Updated 3-Oct-11 21:04pm
v2

Use joins
SQL
Select source, destination, class, [date] 
from table1 
  join table2 on table1.tid = table2.tid

SQL Joins[^]
 
Share this answer
 
v2
Comments
nagendrathecoder 4-Oct-11 3:10am    
IMO, we should let OP learn things by providing them some links rather than providing answers for these simple tasks.
Prerak Patel 4-Oct-11 4:04am    
That's why I provided link to get him started.
You are asking for one of the simplest queries.
You have to use JOINS for achieveing this.
Search GOOGLE if you want to get information about JOINS.
 
Share this answer
 
SQL
select A.tid, A.name, B.class, B.seat from traindetail as A inner join class as B on A.tid=B.tid where A.source = 'SourceFromUser' and A.destination = 'DestinationFromUser' and A.date=convert(datetime,'DateFromUser',103) and B.class='classFromUser'


execute this query and check the row count. if the rowcount is > 0 then display conformation otherwise display appropriate error message.


hope this helps..
 
Share this answer
 

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