List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:August 15 2002 2:32am
Subject:Re: Combining queries
View as plain text  
At 17:37 -0700 8/14/02, Richard Baskett wrote:
>Is there a way to combine these queries?
>
>SELECT count(SeekID) FROM Seekers
>WHERE DateLastLog<NOW() AND DateLastLog>(NOW()-INTERVAL 7 DAY)
>
>SELECT count(SeekID) FROM Seekers
>WHERE DateLastLog<NOW() AND DateLastLog>(NOW()-INTERVAL 1 MONTH)
>
>Or these?
>
>SELECT count(ResumeID) FROM Resumes WHERE testResume='1'
>
>SELECT count(ResumeID) FROM Resumes WHERE HighRank='1'
>
>I've tried a bunch of different group by's but to no avail..

For something like this you want UNION, available in MySQL 4.
Otherwise, you should create a temporary table and then use
INSERT INTO ... SELECT a couple of times.

>
>Also I think I might start looking for a sql/mysql book in the near future
>since there is a lot I am realizing I do not know about sql statements.  Are
>there any that you really really like?  I know MySQL 4.0 will be out
>eventually.. are there any MySQL 4.0 books that people like or should I
>stick with 3.23 books?

4.0 is out now in alpha, and about to go beta with 4.0.3.

>
>Cheers!
>
>Rick

Thread
Speed problems.. StillRichard Baskett15 Aug
  • Re: Speed problems.. StillKeith C. Ivey15 Aug
    • Re: Speed problems.. StillRichard Baskett15 Aug
      • Re: Speed problems.. StillKeith C. Ivey15 Aug
        • Re: Speed problems.. StillRichard Baskett15 Aug
          • Re: Speed problems.. StillKeith C. Ivey15 Aug
            • Combining queriesRichard Baskett15 Aug
              • Re: Combining queriesPaul DuBois15 Aug
          • Re: Speed problems.. StillBenjamin Pflugmann15 Aug
      • Re: Speed problems.. StillSimon Windsor15 Aug
  • Re: Speed problems.. StillRahadul Kabir15 Aug
    • Re: Speed problems.. StillRichard Baskett15 Aug
Re: Combining queriesJerry van Leeuwen15 Aug