Jump to content

[SOLVED] PHP/MySQL Union


dennismonsewicz

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/79997-solved-phpmysql-union/
Share on other sites

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%\")";

Link to comment
https://forums.phpfreaks.com/topic/79997-solved-phpmysql-union/#findComment-405357
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.