The column prefix 'mir' does not match with a table name or alias name used in the query.

Here are my SP.

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS OFF
GO



ALTER    PROCEDURE nk_sp_menu_item_site_recipe_read  
      @menu_item_id int,
      @menu_site_id int
AS


Select mis.*,
msa.preset_total_reimbursable,
msa.preset_total_alacarte

from nk_menu_item_recipe mir,
nk_menu_site_assignment msa
left Join nk_menu_item_site mis on mis.menu_site_id = msa.menu_site_id
and mis.menu_item_recipe_id = mir.menu_item_recipe_id

Where msa.menu_site_id = @menu_site_id
and mir.menu_item_id = @menu_item_id
and msa.menu_letter_id = mir.menu_letter_id

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


THE ERROR IS

Server: Msg 107, Level 16, State 2, Procedure nk_sp_menu_item_site_recipe_read, Line 10
The column prefix 'mir' does not match with a table name or alias name used in the query.

I am scratching my head on this one. Whats wrong with the alias name mir?
LVL 5
lunchbyteAsked:
Who is Participating?
 
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
check whether the table nk_menu_item_recipe  contains the following fields
menu_letter_id
menu_item_recipe_id
menu_item_id
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
ALTER    PROCEDURE nk_sp_menu_item_site_recipe_read  
     @menu_item_id int,
     @menu_site_id int
AS
Select mis.*,
msa.preset_total_reimbursable,
msa.preset_total_alacarte
from nk_menu_item_recipe mir
join nk_menu_site_assignment msa
 on msa.menu_letter_id = mir.menu_letter_id
left Join nk_menu_item_site mis
 on mis.menu_site_id = msa.menu_site_id
and mis.menu_item_recipe_id = mir.menu_item_recipe_id
Where msa.menu_site_id = @menu_site_id
and mir.menu_item_id = @menu_item_id

0
 
lunchbyteAuthor Commented:
I was missing one more table to get the correct menu letter id. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.