因beego的orm无法满足查询要求,需要手写sql语句,然后调用beego的orm.raw()方法,出现syntax error 错误
最开始的sql语句
// 注意like写法%?% 这里是行不通的,需要改成?
num, err := o.Raw("SELECT * FROM registry_info WHERE id IN(SELECT registry_info_id FROM registry_info_edge_mec_types WHERE edge_mec_type_id = ?) AND delete_flag = false AND name LIKE %?%", id, name").
QueryRows(®istryinfos)
//正确写法
num, err := o.Raw("SELECT * FROM registry_info WHERE id IN(SELECT registry_info_id FROM registry_info_edge_mec_types WHERE edge_mec_type_id = ?) AND delete_flag = false AND name LIKE ?", id, "%"+name+"%").
QueryRows(®istryinfos)