可以这样做。。。MSSQL?
其中@myText变量等于字符串"id=5">
SELECT * FROM someTable WHERE ( @myText )
谢谢大家。在你的帮助下,我使用了这样的临时表格…
DECLARE @companies TABLE (comp_code INT) -- create temporary table
INSERT INTO @companies VALUES (5) -- ( repeat this line for each additional company you wish to keep )
DELETE FROM tableOne Where (Comp_Code NOT IN (select comp_code from @companies));
DELETE FROM tableTwo Where (Comp_Code NOT IN (select comp_code from @companies));
DELETE FROM tableThree Where (Comp_Code NOT IN (select comp_code from @companies));
-- etc etc
您需要使用动态SQL。在SQL Server中,这看起来像:
declare @sql nvarchar(max);
set @sql = 'SELECT * FROM someTable WHERE ([myText])';
set @SQL = replace(@sql, '[mytext]', @mytext);
exec sp_executesql @sql;