Problem writing a query to check table vale conflicts

  • Thread starter Thread starter jimc01
  • Start date Start date
J

jimc01

Hello,

I have a database which has a table which is used to summarise future
events. I am trying to write a query which selects job_id from the
table where the value of field called CCT is found in any other record
under a set of fields called RC1 , RC2 , RC3, RC4. I have tried

Select job_id from mytable
where mytable.CCT = mytable.RC1
or mytable.CCT = mytable.RC2
or mytable.CCT = mytable.RC3 ....

but this only selects records where RC1 and CCT values are the same,
have also tried

select job_id from mytable
where mytable.CCT in (mytable.RC1,mytable.RC2,mytable.RC3)

but this doesn't return any values.

Is there a simple solution I am missing ?

JimC
 
SO if the Value of CCT appears in RC1 in ANY record in the database, then you
want to return that record. The same for Rc2, Rc3, and Rc4. Is that correct?
IF so, then you might try a query that looks like the following

SELECT Job_Id
FROM MyTable
WHERE CCT in
(SELECT RC1 FROM MyTable)
OR
CCT in
(SELECT RC2 FROM MyTable)
OR
CCT in
(SELECT RC3 FROM MyTable)
OR
CCT in
(SELECT RC4 FROM MyTable)
 
Back
Top