List:General Discussion« Previous MessageNext Message »
From:Joppe A Date:February 28 2005 1:20pm
Subject:Fwd: how can I do instead of using subselects?
View as plain text  
Please help, this must be easy for experinced MySQL users but for me as a newbie isn't it.
I have tried to find the answer on the things below in older MySQL manuals but without any
success... 

I have a problem with a few sql-queries because I have written the questions with
subselect statements and then will they not work on older MySQL DB:s. Can any one help me
to say haw to solve it without subselect! 

Today looks the questions like this and works fine in MySQL 4.x.x but not in 3.23.55 where
I also need to use them:

SELECT (SELECT count(SUB.S_ID) FROM SUB 
  LEFT JOIN SUBS ON SUBS.S_ID = SUB.S_ID)
    /(SELECT COUNT(*) from SUB);

SELECT COUNT(SUBS.NEW_ID)+(SELECT COUNT(SUBS_D.NEW_ID)
 FROM SUBS_D WHERE
   SUBS.NEW_ID=SUBS_D.NEW_ID)
     FROM SUBS WHERE SUBS.NEW_ID=1; 

SELECT (SELECT count(*) from SUBS)-(SELECT count(SUBS.S_ID) FROM SUB LEFT JOIN SUBS ON
SUBS.S_ID = SUB.S_ID)+(SELECT count(*) FROM SUBS_D); 


Another question is how do I do when I want to compare two tables, normally is it no
problem to get a list with rows that exist i both tables, but how do I do if I want to to
have the diffrence listed instead, the rows that only appears in one of the tables?

Thanks in advance!

/Joppe



-- 
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm

Thread
Fwd: how can I do instead of using subselects?Joppe A28 Feb
  • Re: Fwd: how can I do instead of using subselects?Peter Brawley28 Feb