nasty SQL query, please advise...



Three tables: clients, coverage, visits
A client may have one or more coverages. A coverage may have one or
more visits.

Clients pk: clientID
coverage pk: covID, fk:clientID
visits pk: visitID, fk:covID

The query is this:
The visits table needs to store the client number for the client whose
visit this is for (don't ask why...)

I'm not sure how to express the SQL. Here's a beginning:

UPDATE visits
SET clientnum = (SELECT clientID from clients c
LEFT JOIN coverage v on c.clientID = v.clientID
LEFT JOIN visits t on v.covID = t.covID
WHERE .....???? )

I don't know what to put in the WHERE clause.

-Corinna

.



Relevant Pages

  • Re: www.petassure.com
    ... It's like any insurance coverage - a gamble that you won't need it. ... of clients vs. outgo of clients' coverage). ... If the $6.50 is because your company is subsidizing it, ...
    (rec.pets.cats.anecdotes)
  • Re: nasty SQL query, please advise...
    ... > Three tables: clients, coverage, visits ... > I don't know what to put in the WHERE clause. ... Visits table as referenced by the UPDATE query itself, ...
    (comp.lang.pascal.delphi.misc)
  • Re: Best wifi location?
    ... I've had clients that love the wifi at Coronado Springs. ... Coverage is pretty good, although not ...
    (rec.arts.disney.parks)
  • Re: Canadian outsourcing - did not know this
    ... If I lose clients over it so be it! ... Barb - just holler if you need some coverage. ...
    (sci.med.transcription)
  • Re: Outlook 2003 connected to Exchange 2003 through firewall
    ... >>> recommending that sort of topology separating the clients and the ... >>> server with a firewall. ... Prev by Date: ...
    (microsoft.public.exchange.clients)