• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
union all?

#2
[eluser]Phil Sturgeon[/eluser]
You need to get the same number of fields being returned by each statement within the union. That means instead of using * use actual fieldnames and aliases to call them all the same thing.

Code:
( SELECT fieldA as first_thing, fieldB as second_thing FROM table1 )
UNION
( SELECT fieldX as first_thing, fieldY as second_thing FROM table2 )

And no there is no way to handle this with active record ;-)


Messages In This Thread
union all? - by El Forum - 05-26-2009, 12:47 AM
union all? - by El Forum - 05-26-2009, 02:27 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.