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?
 
Ashish PatelConnect With a Mentor Commented:
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
 
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
All Courses

From novice to tech pro — start learning today.