dennismonsewicz Posted December 3, 2007 Share Posted December 3, 2007 I am doing a text search and the PHP code that processes the SQL command searches two database tables using the union command. I was wondering if there is a way to add a third, fourth, fifth, and so on. Right now if I add any more the application breaks. Any ideas? Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 3, 2007 Share Posted December 3, 2007 Yes you can. You might be using the syntax wrong. You could post the query you are using and see if someone can find somethig wrong. Here is the documentation for the UNION statement: http://dev.mysql.com/doc/refman/5.1/en/union.html Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 3, 2007 Author Share Posted December 3, 2007 here is my union statment: $query = "(select * from arcamax where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from drudge where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from google where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from human_events where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from newsmax where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from street where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from townhall where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from weatherbug where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\") union (select * from worldnet where promo_code like \"%$trimmed%\" or start_end_date like \"%$trimmed%\" or mailedlist like \"%$trimmed%\" or description like \"%$trimmed%\" or orders like \"%$trimmed%\" or totalrevenue like \"%$trimmed%\")"; Quote Link to comment Share on other sites More sharing options...
lemmin Posted December 11, 2007 Share Posted December 11, 2007 Are you getting an error, or is the query just not returning any results (or the wrong results)? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.