PHP Union statement has stopped working.

Hello,

I have this UNION statement that was working fine until 2 days ago.

      $debtlistq = "(SELECT * FROM mortgage WHERE mort_application_date IS NOT NULL $month_select $quarter_select $year_select) UNION (SELECT * FROM remortgage WHERE mort_application_date IS NOT NULL $month_select $quarter_select $year_select) UNION (SELECT * FROM b2l WHERE mort_application_date IS NOT NULL $month_select $quarter_select $year_select) ORDER BY mort_application_date DESC";

Each Select statement works fine individually and statements 1 and 2 work fine when UNION. But if UNION any other statement with the 3rd statement i dont get any rows outputted.

Is there a line of code i can use to find out where the error is?
Thanks
AR
drews1fAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ashish PatelCommented:
instead of using SELECT * you better specify the column names and please note that column names for all 3 statements should be of same no. and type.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
drews1fAuthor Commented:
i had added an extra field to tables mortgage and remortgage and forgot to add it to b2l. I added it to b2l and all is well again :) thanks anyway!

AR
0
Ashish PatelCommented:
good, so, always have a practice of specifying column names instead of using *. That would be a good standard. Please close the question if your issue is solved.
0
drews1fAuthor Commented:
i will give you the points as you actually had the right answer ish :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.