Re: Can some explain this to me?



. The mistake I made was that the column pers_companyid does not exist. It should have been comp_companyid. <<

Google for a recent posting of mine on scoping rules in SQL. Then
learn how to properly name data elements -- why is a personnel
company_id a totally different kind of attribute from a company
company_id? That is what different names imply! If you had obeyed
ISO-11179, your query would have run as intended.

DELETE FROM Personnel -- collective name
WHERE company_id -- scopes to Personnel
IN (SELECT company_id -- scopes to Companies
FROM Companies -- plural name
WHERE contract_expiry IS NOT NULL);

Do entire companies expire in your data model? or does some
relationship between them and your personnel expire?

Get a copy of SQL PROGRAMMING STYLE and it will help clear up your
thinking.


.



Relevant Pages

  • Re: Damsel in distress!
    ... I am trying to write this in SQL and your post ... >CREATE TABLE TimeCards ... > FROM Personnel AS P1, ... > Calendar AS C1 ...
    (microsoft.public.sqlserver.programming)
  • Re: Alternative for TOP
    ... SELECT TOPis a proprietary feature that was easy to implement in SQL ... The idea is take each salary and build a group of other salaries ... by changing @n and playing with the two comparison operators. ... FROM Personnel AS P1, Personnel AS P2 ...
    (microsoft.public.sqlserver.programming)
  • Re: Need query to return absence of record
    ... time I do the query. ... FROM Personnel As P LEFT JOIN TrainingHistory As T ... I put in the SQL (except I changed T,ClassName is Null to T.Classname ...
    (microsoft.public.access.queries)
  • Re: Need query to return absence of record
    ... time I do the query. ... FROM Personnel As P LEFT JOIN TrainingHistory As T ... I put in the SQL (except I changed T,ClassName is Null to T.Classname ...
    (microsoft.public.access.queries)