hi,
i've got problem on how to query my two tables:
Table statuslog
FIELDS: row1 row2
ActId : 1 2
ActDate : 2005-9-19 2005-9-18
PIN(employee) : P120 P120
ProjCode : 1234 123
ActCode : B I
Map# : map1 kd145
RegHrs : 0.5 7.0
OtHrs : 0 2.0
Status(%) : 20 100
Table DalsDataNew
FIELDS: row1 row2
ID : 24 25
Date : 2005-9-19 2005-9-18
PIN(employee) : P120 P120
ProjCode : 1234 123
ActCode : B I
ActMedium : W(PC) W(PC)
Map# : map1 kd145
RegHrs : 0.5 7.0
OtHrs : 0 2.0
Flag : 0 1
Approved by : P084 P083
if you will notice some fields of my tables have same value. these are: Date,ProjectCode,ActCode,RegHrs,OtHours
what i would like my output(data) to be in my datagrid:
ActId,ID,Date,ProjectCode,ActCode,ActMedium,RegHrs,OTHrs,Status,Flag,Approved by
i have this query in 1 table only.
"SELECT * FROM statuslog WHERE statuslog.Pin = '"+Session("user")+"' and statuslog.ActDate >= '"+DateFirst+"' and statuslog.ActDate <= '"+DateEnd+"' ORDER BY statuslog.ActDate DESC"
but what i would do now is to query the two tables and same where clause in the query above.
You need to do a query using INNER JOIN.
This article should help:
http://www.devx.com/dbzone/Article/17403/1954?pf=true
No comments:
Post a Comment