mysql_query UNION循环

时间:2017-01-06 04:53:13

标签: mysql loops union

我如何使用循环执行与下面脚本相同的操作?



$res = mysql_query("SELECT * FROM {$table_1} WHERE txn_id LIKE '%{$txn_id}%'
					UNION
					SELECT * FROM {$table_2} WHERE txn_id LIKE '%{$txn_id}%'
					UNION
					SELECT * FROM {$table_3} WHERE txn_id LIKE '%{$txn_id}%'
					UNION
					SELECT * FROM {$table_4} WHERE txn_id LIKE '%{$txn_id}%'
					UNION
					SELECT * FROM {$table_5} WHERE txn_id LIKE '%{$txn_id}%'




感谢。

0 个答案:

没有答案