scripter73
Programmer
Hi,
I'm trying to do a join of 3 tables in a SQL query. Everything works fine until I include the 3rd table. I want to pull only those records where fields of the 3rd table match portions of a field from the 1st table. I thought I could do it by including a String parsing function within the SQL, but I get an error "MID in *LIBL type *N not found.
"
My code follows and I'll bold the section where I use the 3rd table. My question is can I do this? Is my syntax correct? Should I just do a separate query, etc.?
<cfquery name="newdata" datasource="#session.dsn#">
select PLWEBNEW.wnew_policy_alpha,
PLWEBNEW.wnew_policy_number,
PLWEBNEW.wnew_agent_code,
PLWEBNEW.wnew_issued_date,
PLWEBNEW.wnew_pol_code,
PLWEBNEW.wnew_master_agent,
PLWEBPOL.wpol_renewal_seq_number,
PLWEBPOL.wpol_endorsement_no,
PLWEBPOL.wpol_ins_first_name,
PLWEBPOL.wpol_ins_last_name,
PLWEBPOL.wpol_ins_mi,
PLWEBPOL.wpol_binder_number,
PLWEBPOL.wpol_eff_date,
PLWEBPOL.wpol_quoted_tot,
ARIVR.vr00_branch,
ARIVR.vr00_company,
ARIVR.vr00_product,
ARIVR.vr00_policy_number,
ARIVR.vr00_uprate_reasons,
ARIVR.vr00_orig_issued_tot
from PLWEBNEW,PLWEBPOL,ARIVR
<cfif Left(#session.agentcode#,1) eq "G">
<!--- <cfset session.mastercode = #session.agentcode#> --->
where (wnew_master_agent = '#session.agentcode#' AND wnew_pol_code = 'N'
AND PLWEBNEW.wnew_policy_alpha = PLWEBPOL.wpol_policy_alpha AND PLWEBNEW.wnew_policy_number = PLWEBPOL.wpol_policy_number AND ARIVR.vr00_branch = Mid(PLWEBNEW.wnew_policy_alpha,1,2) and ARIVR.vr00_company = Mid(PLWEBNEW.wnew_policy_alpha,3,2) and ARIVR.vr00_product = Mid(PLWEBNEW.wnew_policy_alpha,5,2) and ARIVR.vr00_policy_number = PLWEBNEW.wnew_policy_number)
<cfelse>
where wnew_agent_code = '#session.agentcode#' and wnew_pol_code = 'N'
</cfif>
order by wnew_issued_date
</cfquery>
Thanks in advance for your help,
scripter73
Change Your Thinking, Change Your Life.
I'm trying to do a join of 3 tables in a SQL query. Everything works fine until I include the 3rd table. I want to pull only those records where fields of the 3rd table match portions of a field from the 1st table. I thought I could do it by including a String parsing function within the SQL, but I get an error "MID in *LIBL type *N not found.
"
My code follows and I'll bold the section where I use the 3rd table. My question is can I do this? Is my syntax correct? Should I just do a separate query, etc.?
<cfquery name="newdata" datasource="#session.dsn#">
select PLWEBNEW.wnew_policy_alpha,
PLWEBNEW.wnew_policy_number,
PLWEBNEW.wnew_agent_code,
PLWEBNEW.wnew_issued_date,
PLWEBNEW.wnew_pol_code,
PLWEBNEW.wnew_master_agent,
PLWEBPOL.wpol_renewal_seq_number,
PLWEBPOL.wpol_endorsement_no,
PLWEBPOL.wpol_ins_first_name,
PLWEBPOL.wpol_ins_last_name,
PLWEBPOL.wpol_ins_mi,
PLWEBPOL.wpol_binder_number,
PLWEBPOL.wpol_eff_date,
PLWEBPOL.wpol_quoted_tot,
ARIVR.vr00_branch,
ARIVR.vr00_company,
ARIVR.vr00_product,
ARIVR.vr00_policy_number,
ARIVR.vr00_uprate_reasons,
ARIVR.vr00_orig_issued_tot
from PLWEBNEW,PLWEBPOL,ARIVR
<cfif Left(#session.agentcode#,1) eq "G">
<!--- <cfset session.mastercode = #session.agentcode#> --->
where (wnew_master_agent = '#session.agentcode#' AND wnew_pol_code = 'N'
AND PLWEBNEW.wnew_policy_alpha = PLWEBPOL.wpol_policy_alpha AND PLWEBNEW.wnew_policy_number = PLWEBPOL.wpol_policy_number AND ARIVR.vr00_branch = Mid(PLWEBNEW.wnew_policy_alpha,1,2) and ARIVR.vr00_company = Mid(PLWEBNEW.wnew_policy_alpha,3,2) and ARIVR.vr00_product = Mid(PLWEBNEW.wnew_policy_alpha,5,2) and ARIVR.vr00_policy_number = PLWEBNEW.wnew_policy_number)
<cfelse>
where wnew_agent_code = '#session.agentcode#' and wnew_pol_code = 'N'
</cfif>
order by wnew_issued_date
</cfquery>
Thanks in advance for your help,
scripter73
Change Your Thinking, Change Your Life.