Hey,
Thanks for replying.

Nope, the whole reason for selecting the data is the count, i need to
display to the client how many records of each category he has...if there is
any other way to do that (me being a newbie to mysql) I would happy to know
of it.

Cheers,
-Ryan


> Without 'count' function, you could have:
>
> SELECT user.C1, dedicated.C2, reseller.C3, colocated.C4, freehosting.C5
> FROM user, dedicated, reseller, colocated , freehosting WHERE
> (user.user ='testing' and  user.ccno=1) OR
> (dedicated.user ='testing' and  dedicated.ccno=1) OR
> (reseller.user ='testing' and  reseller.ccno=1) OR
> (colocated.user ='testing' and  ccolocated.cno=1) OR
> (freehosting.user ='testing' and  freehosting.ccno=1) OR
>
>
>
> Ryan A wrote:
> > Hi guys,
> > First of all let me warn you, i am very much a newbie to mysql, i am
pretty
> > good with the basics like selecting,deleting,updateing etc but after
that i
> > get a dazed look in my eyes with complex sql :-D
> >
> > Now that you have been warned let me explain, on my local machine
(win2k) i
> > have php and mysql 4.0 installed for testing purposes, I have created a
site
> > locally and then uploaded it only to find out that because of  UNION it
wont
> > run as my host is on version 3.23.
> >
> > I then searched google as i was pretty sure that i am not the only
person
> > who ran into this problem and found 2 places with some kind of
explanation
> > of which this seems to be the best:  (the other one is the online
manual)
> > http://jinxidoru.com/tutorials/union.html
> >
> > but being a newbie and never having used "join" in my life, (at least
not
> > knowingly) this is @$#$%^$ confusing.
> >
> > Below is my union select statement, can somebody please show me how to
> > convert it so it will work on 3x please?
> > (This one is the actual php code i am using but if you dont understand
it
> > there is the normal sql below this one)
> >
> > $tt = "SELECT  COUNT(*), 'C1' FROM shared WHERE user ='".$mmmy_user."'
and
> > ccno=".$mmmy_ccno." UNION SELECT COUNT(*), 'C2' FROM dedicated where
> > user='".$mmmy_user."' and  ccno=".$mmmy_ccno." UNION SELECT  COUNT(*),
'C3'
> > FROM reseller WHERE user ='".$mmmy_user."' and  ccno=".$mmmy_ccno."
UNION
> > SELECT COUNT(*), 'C4' FROM colocated WHERE user ='".$mmmy_user."' and
> > ccno=".$mmmy_ccno." UNION SELECT COUNT(*), 'C5' FROM freehosting WHERE
user
> > ='".$mmmy_user."' and  ccno=".$mmmy_ccno;
> >
> > // Normal version
> >
> > SELECT  COUNT(*), 'C1' FROM shared WHERE user ='testing' and  ccno=1
> > UNION
> > SELECT COUNT(*), 'C2' FROM dedicated where user='testing' and  ccno=1
> > UNION
> > SELECT  COUNT(*), 'C3' FROM reseller WHERE user ='testing' and  ccno=1
> > UNION
> > SELECT COUNT(*), 'C4' FROM colocated WHERE user ='testing' and  ccno=1
> > UNION
> > SELECT COUNT(*), 'C5' FROM freehosting WHERE user ='testing' and
ccno=1;
> >
> > Thanks in advance and have a fantastic day, even though its monday...
> > :-D
> >
> > Cheers,
> > -Ryan
> >
> >
>
>


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to