Union query help

holtzy
01-13-2004, 04:17 PM
After reading several threads about union queries I came up with this:

"SELECT Sum(views) AS SumViews1 FROM Vehicles Where O_AirBag = 'true' UNION SELECT Sum(views) AS SumViews2 FROM Vehicles Where O_DualAirBag = 'true'"

but it errors out. If I run it without the union, and run each sql statement seperately they run fine. Why isn't the union working? Any ideas?

Optikal
01-13-2004, 04:22 PM
you have to name the fields the same name. Change SumViews2 to be SumViews1

holtzy
01-13-2004, 04:48 PM
Nope, still saying i have an error in my sql syntax. Maybe something is up with my database?

holtzy
01-13-2004, 05:16 PM
I checked my php version and it is above 4 so it is supposed to accept union queries.

Optikal
01-13-2004, 05:21 PM
it should have nothing to do with your php version, it should be dependent on your MySQL version.

holtzy
01-13-2004, 05:25 PM
I'll have to check and see what version it is, but I'm pretty sure it's a recent version.

Dennis DVR
01-14-2004, 04:03 AM
what happend if you remove the first where?

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum