给定一个包含 3 列的表:C1、C2、C3
C1 - C2 - C3 M - 是 - M1 N2 - 是 - N3 M2 - 是 - M3 M3 - 是 - M4 N1 - 是 - N2 M1 - 是 - M2 N - 是 - N1
如何将此 Simple SQLServer 语句转换为 MySQL 语句:
declare @searchString varchar(32) = 'M';
with cte(results) as
(
select C3 from Tbl where C1 = @searchString
union all
select t.C3 from Tbl t inner join cte c on c.C3 = t.C1
) select * from cte;