postgresql psql在Join语句中将文本输入视为列[duplicate]

5kgi1eie  于 2023-01-30  发布在  PostgreSQL
关注(0)|答案(1)|浏览(147)
    • 此问题在此处已有答案**:

Column 'mary' does not exist(2个答案)
3天前关闭.

SELECT DISTINCT midiport_id, mp.implementation, d.device_function, mp.serial, mp.dev, mp.subdev, mc.device_id, mc.target, mc.mask, mf.midi_function_id, kd.divn, mc.dev, mc.channel, d.inputs, d.outputs, mc.lo_key, mc.hi_key, mc.program, mc.case_value, mc.num_value, mc.tab_device_id, mf.status, pd.divn, mp.local_port, mp.console_id, mc.controlling_tab_device_id, mc.controlling_tab_default, mp.digit_offset, mp.digit_size 
FROM midiport mp join console c on c.console_id = mp.console_id and mp.console_id = 652 
JOIN midi_input_rules mc USING (midiport_id) 
JOIN device d ON (d.device_id = mc.device_id) join midi_function mf on mf.name = mc.datasource 
LEFT OUTER JOIN pipe_division kd ON kd.key_division_id = mc.key_division_id 
LEFT OUTER JOIN pipe_division pd ON pd.pipe_division_id = mc.pipe_division_id 
where kd.divn is null or kd.divn = (select min(divn) from pipe_division pdm where mc.key_division_id = pdm.key_division_id)
AND mp.implementation != ‘play’ ORDER BY midiport_id, mc.case_value, mc.channel, mc.target, mc.mask;

如果我简单地在midport表上运行最终WHERE条件,它就可以工作。但是,在这个JOIN语句中,由于某种原因,'play'产生了一个语法错误(column "'play'" does not exist)。为什么在正常情况下它接受文本值,而在这里却被视为一列?

41zrol4v

41zrol4v1#

"play"这个单引号不对。
试试这个

SELECT DISTINCT midiport_id, mp.implementation, d.device_function, mp.serial, mp.dev, mp.subdev, mc.device_id, mc.target, mc.mask, mf.midi_function_id, kd.divn, mc.dev, mc.channel, d.inputs, d.outputs, mc.lo_key, mc.hi_key, mc.program, mc.case_value, mc.num_value, mc.tab_device_id, mf.status, pd.divn, mp.local_port, mp.console_id, mc.controlling_tab_device_id, mc.controlling_tab_default, mp.digit_offset, mp.digit_size 
FROM midiport mp join console c on c.console_id = mp.console_id and mp.console_id = 652 
JOIN midi_input_rules mc USING (midiport_id) 
JOIN device d ON (d.device_id = mc.device_id) join midi_function mf on mf.name = mc.datasource 
LEFT OUTER JOIN pipe_division kd ON kd.key_division_id = mc.key_division_id 
LEFT OUTER JOIN pipe_division pd ON pd.pipe_division_id = mc.pipe_division_id 
where kd.divn is null or kd.divn = (select min(divn) from pipe_division pdm where mc.key_division_id = pdm.key_division_id)
AND mp.implementation != 'play' ORDER BY midiport_id, mc.case_value, mc.channel, mc.target, mc.mask;

相关问题