5 replies
by brian Accepted solution
by robo_dev Accepted solution
Post your query, what it's returning as-is, and some info about the tables it's pulling from, such as what the primary key is.
Also, what database are you using?
At a high level, what you are doing is called an inner-join
by brian Accepted solution
The Primary key that ties all of this togeather is the report number (reportid). I am using a data grid to display the information in html. I can get it to display all informaiton for dbo.reports, but can not get it to display information for dbo.comments or dbo.meeting_actions. The system will return nothing (no null values, but a blank white screen) when this is done as a query.
SELECT ISNULL(dbo.reports.eagentid, 0) AS newEagentId, dbo.reports.reportid, dbo.reports.urgent, dbo.reports.client, dbo.reports.address, dbo.reports.city,
dbo.reports.state, dbo.reports.zip, dbo.reports.deptid, dbo.reports.customer_comment, dbo.reports.action_agent, dbo.reports.action_date,
dbo.reports.action, dbo.reports.et_error, dbo.reports.ts_error, dbo.reports.pf_error, dbo.reports.rf_error, dbo.reports.te_error, dbo.reports.af_error,
dbo.reports.ae_error, dbo.reports.phone, dbo.reports.agentid, dbo.reports.bagentid, dbo.reports.date, dbo.reports.status, dbo.reports.traveler,
dbo.reports.nts_error, dbo.reports.supplier, dbo.reports.pcomment, dbo.reports.crequest, dbo.reports.internaldoc, dbo.reports.oagentid,
dbo.reports.pnr, dbo.reports.destination, dbo.reports.dep_date, dbo.reports.refund, dbo.reports.dmemo, dbo.reports.ticket_num,
dbo.reports.cash_expense, dbo.reports.money_due, dbo.reports.reimbursement, dbo.reports.gift_Certificate, dbo.reports.etravel,
dbo.Comment.date AS Expr1, dbo.Comment.agentid AS Expr2, dbo.Comment.comment, dbo.meeting_actions.date AS Expr3,
dbo.meeting_actions.agentid AS Expr4, dbo.meeting_actions.maction
FROM dbo.reports INNER JOIN
dbo.Comment ON dbo.reports.reportid = dbo.Comment.reportid INNER JOIN
dbo.meeting_actions ON dbo.reports.reportid = dbo.meeting_actions.reportid
WHERE (dbo.reports.reportid = '12345')
by tony hopkinson Accepted solution
Given you could have data in 2 or 3 or both or neither that's two outer joins of the same field.
Given
Table1 is
RowNumber,
SomeText
Table2 is
RowNumber
AgentComment
Table3 is
RowNumber
AdminComment
then
select RowNumber, "Agent" as CommentType,AgentComment as Comment
Union
select RowNumber, "Admin", AdminComment
will give you all the comments and a type
So
Select Table1.*, CommentType, Comment
inner join (select RowNumber, "Agent" as CommentType,AgentComment as Comment
Union
select RowNumber, "Admin", AdminComment
) comments On Table1.RowNumber = Comments.RowNumber
Where SomeDate Between StartDate and EndDate
might be a bit easier to get the head round.
If you want table 1 records without any comments change inner to outer.
Should work I think.
HtHs
by brian Accepted solution
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending