Don't you hate having to deal with someone elses bad design <g>.  Actually it beats dealing with your own bad design -
at least you can point a finger (ha).
  -----Original Message-----
  From: Bruce, Rodney S HQISEC/Veridian IT Services [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, March 09, 2004 12:07 PM
  To: CF-Talk
  Subject: RE: SQL Help

  Need to play around with this for awhile and see what I get.
  For some reason thought I tried NOT LIKE, but dont remember now ;o\

  Agreed this is not a very good way to handle this. I did not designed the DB
  nor can I change it.
  Have to work with what they gave me.

  -----Original Message-----
  From: Mark A. Kruger - CFG [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, March 09, 2004 10:12 AM
  To: CF-Talk
  Subject: RE: SQL Help

  How about:

  WHERE  (name LIKE '%Open%'  or name LIKE '%Engineering%') AND name NOT LIKE
  ('%closed%')

  Personally, this is probably not the best way to handle status.  I always
  have a status field - either an int or a small character field and use a
  constraint
  ('open','closed','pending') and always be assured of a proper status.

  -Mark

  gets me projects that are closed as well as open
  -----Original Message-----
  From: Bruce, Rodney S HQISEC/Veridian IT Services
  [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, March 09, 2004 10:41 AM
  To: CF-Talk
  Subject: SQL Help

  Hi all

  I need some help with a query that supplies a report.

  The issue for me is one of the tables: (simplified)

  Table
  UID   Name     Description  Parent  Project_id

  This table contains different information in the same field (name),like the
  projects status (Initializing, Engineering, etc) , the type of project
  (Contractor, Govt), and condition (Open, Closed).

  So projects can have 1, 2 or 3 records in this table.

  The problem is if the user wants a report of all Open-Engineering-Govt
  projects.

  Name is a Text field.

  So I can get all the open with:

  WHERE name LIKE '%Open%'
  (needs to be LIKE because the information is not consistant, ie:  Open, is
  Open,  Opened, etc).

  But

  WHERE name LIKE '%Open%' and name LIKE '%Engineering%'
  gets me nothing becuase the field cant be both at same time

  and
  WHERE name LIKE '%Open%'  or name LIKE '%Engineering%'
  gets me projects that are closed as well as open

  I can get the information I need by running mulitple queries:

  <CFQUERY name="first">
      WHERE name LIKE '%Open%'
  </CFQUERY>

  <CFOUTPUT query="first">
          <CFQUERY name="second">
              WHERE name LIKE '%Engineering%' and project_ID =
  #first.project_id#
          </CFQUERY>
      <CFIF second.recordcount GT 0>
          is both opened and Engineering.
      </CFIF>
  </CFOUTPUT>

  But this is cumbersome.

  anyone know a better way?

  We are using:  CF5 and SQL 2000.

  Thanks
  Rodney
    _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to