在线等 速给分 子查询
select sportman_waichu.*,now_unit,coach from sportman_waichu left join sportman on sportman.sp_ID=sportman_waichu.sp_ID
这句查询得到的结果为
因为用到了左连接 我想在查询得到的结果多加个条件 coach=“变量”
------解决方案--------------------
试试这个:
select sportman_waichu.*,now_unit,coach from sportman_waichu left join sportman on sportman.sp_ID=sportman_waichu.sp_ID
where coach='变量'
------解决方案--------------------select?sportman_waichu.*,now_unit,coach?
from?sportman_waichu?left?join?sportman?on?sportman.sp_ID=sportman_waichu.sp_ID
WHERE coach='变量'
------解决方案--------------------你这个要用动态SQL吧,你的变量的意思是传入的值吧
declare @var int
set @var = 123
declare @sql varchar(256)
set @sql = 'select sportman_waichu.*,now_unit,coach from sportman_waichu left join sportman on sportman.sp_ID=sportman_waichu.sp_ID where coach='+@var
exec(@sql)