mysql question and a really bad joke

From: Alexander Ross (alexross_at_bleen.net)
Date: 03/21/04


Date: Sun, 21 Mar 2004 02:38:01 GMT

Lets say I have 2 tables, tbl_topics and tbl_lessons:

tbl_topics

      topicID
     INT

      parentID
     INT

      Title
     VARCHAR

tbl_lessons

      lessonID
     INT

      topicID
     INT (FK)

      Other fields

I have a query that gives me all the topics who's parentID = $whatParentID
:

"SELECT topicID FROM tbl_topics WHERE parentTopicID=$whatTopicID"

Now I want to modify this query so I get a second column called count that
contains the number of times the returned topicID is found in tbl_lessons
even if that count is 0.

Example result:

      topicID
     Count

      1000
     2

      1003
     0

      1021
     4

In this example, topics 1000,1003,and 1021 all have a parentID of 1009 (or
whatever) and 1000 has 2 lessons, 1003 has 0, and 1021 has 4.

Anyone? Anyone? Bueller? Bueller?

BAD JOKE: (read this outloud)

Have you heard about circus sex? its in tents.



Relevant Pages

  • Return Hierarchical Data From One Table (with a JOIN to a second table)
    ... I would appreciate help in designing an efficient query that will retrieve ... [SequenceInRank] ... - specifies which row is the logical parent of the ...
    (microsoft.public.sqlserver.programming)
  • [GIT PULL] post-2.6.17-rc1 fixes
    ... Wait for join to finish before freeing mcast struct ... int ret; ... Otherwise it is a query ID that can be used to cancel ...
    (Linux-Kernel)
  • Re: Need assistance with query
    ... Using that query, you can't do that. ... Declare @OKI int -- OKIData Printer ... Declare @ESI int -- ESI Printer boxes ...
    (microsoft.public.sms.admin)
  • Rewrite Query for tuning.
    ... The Query returns rows. ... CONSTRAINT PRIMARY KEY CLUSTERED ...
    (microsoft.public.sqlserver.programming)
  • Re: NULLs: theoretical problems?
    ... create view C(x int, y int) ... as select blah as x, ... the same supertype, int), the query is completely valid, and returns neither ... Don't you mean subordinate clauses in the WHERE clause? ...
    (comp.databases.theory)