在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/數(shù)據(jù)庫/ SQL 求助: 遍歷一個存了 table 名和 column 名的表,驗證是否匹

SQL 求助: 遍歷一個存了 table 名和 column 名的表,驗證是否匹配某個值

假設(shè)表格 Summary 如下:

TableName ColName Desc
t1 c1 blah blah
t2 c2 blah blah
t3 c3 blah blah

求哪位大神給指導(dǎo)下,怎么寫一個 stored procedure, 傳進一個 int 參數(shù),然后返回是否有某個 TableName 里的 ColName 的值與它匹配?

例:
傳進 2, 遍歷 t1 表格里的 c1, t2 表格里的 c2, t3 表格里的 c3,看看是否有一個的值為 2

主要是這里怎么遍歷這個 Summary 表,并且獲得 TableName 中 ColName 的值來與傳進的參數(shù)相比較

回答
編輯回答
心悲涼
select c1 as res from t1 where c1=2
union
select c2 as res from t2 where c2=2
union
select c3 as res from t3 where c3=2
....
2018年6月25日 23:45