-1
select rm_id as 'ID'
        bk_branch as 'BRANCH'
        br_name as 'BANK REP.'
        bs_name as 'ESCORT'
        dt_rep  as 'DATE'
        rep_time as 'TIME'
        amt
        inv_no
        total_box
        box_no
        note_state
        dm_state
        1
        2
        10
        20
        50
        100
        500
        1000
        tp
        tv
        tp_ex1
        tv_ex1
        tp_m
        tv_m         
from bk_det 
inner join bk_rep 
  on bk_det.rm_id =  bk_rep.rm_id
inner join bk_sec 
  on bk_rep.rm_id = bk_sec.rm_id
inner join mut_det 
  on bk_sec.rm_id =  mut_det.rm_id
inner join rm_det 
  on mut_det.rm_id = rm_det.rm_id
inner join soil_det 
    on rm_det.rm_id = soil_det.rm_id

我已经从我的表中编写了上面的代码,但没有运行它的显示错误:

消息 102,级别 15,状态 1,第 2 行
'bk_branch' 附近的语法不正确。

请帮忙..!!

4

2 回答 2

3

您需要将 by 中的字段SELECT分开,。连接本身在语法上看起来不错。

select rm_id as 'ID'
        ,bk_branch as 'BRANCH'
        ,br_name as 'BANK REP.'
        ,bs_name as 'ESCORT'
        ,dt_rep  as 'DATE'
        ,rep_time as 'TIME'
        ,amt
        ,inv_no
        ,total_box
        ,box_no
        ,note_state
        ,dm_state
        ,1
        ,2
        ,10
        ,20
        ,50
        ,100
        ,500
        ,1000
        ,tp
        ,tv
        ,tp_ex1
        ,tv_ex1
        ,tp_m
        ,tv_m         
from bk_det 
...
于 2012-12-29T16:14:38.917 回答
0

只需将表别名赋予列,否则会产生歧义。

select a.rm_id as 'ID',
        bk_branch as 'BRANCH',
        br_name as 'BANK REP.', 
        bs_name as 'ESCORT',
        dt_rep  as 'DATE',
        rep_time as 'TIME',
        amt,
        inv_no,
        total_box,
        box_no,
        note_state,
        dm_state,
        1 ,
        2,
        10,
        20,
        50,
        100,
        500,
        1000,
        tp,
        tv,
        tp_ex1,
        tv_ex1,
        tp_m,
        tv_m,         
from bk_det a
inner join bk_rep b
  on a.rm_id =  b.rm_id
inner join bk_sec c 
  on b.rm_id = c.rm_id
inner join mut_det d
  on c.rm_id =  d.rm_id
inner join rm_det e
  on d.rm_id = e.rm_id
inner join soil_det f
    on e.rm_id = f.rm_id;
于 2012-12-29T16:32:36.903 回答