views:

16

answers:

1

I have a Select Left Join Query whis displays me the rows for the latest changedone(its a time) column name ("field" should not be equal) column name ("trackid" should not be equal), and column name "Operation should be "UPDATE" ", below is the query I am talking about...

SELECT j1. *
FROM jos_audittrail j1
LEFT OUTER JOIN jos_audittrail j2 ON ( j1.trackid != j2.trackid
AND j1.field != j2.field
AND j1.changedone < j2.changedone )
WHERE j1.operation = 'UPDATE'
AND j2.id IS NULL

I get the result with field value as either "lastvisitDate" or "hits"

Now here I don't want a row to be displayed with a two particular column's value i.e. "field's value" the value is "lastvisitDate" and "hits"

Now if i append the condition in the above query that " AND j1.field != 'lastvistDate' AND j1.field != 'hits' " then i do not get any result...

The table structure is

jos_audittrail:

  1. id
  2. trackid
  3. operation
  4. oldvalue
  5. newvalue
  6. table_name
  7. live
  8. changedone(its a time)

I hope i have given the details properly If u still find something missing I will try to provide it more better way...

Pls help me to avoid those two rows with those to mentioned value of "field"

+1  A: 

I Changed My select query this way and I got the result the way I needed

SELECT j1. *
FROM jos_audittrail j1
LEFT OUTER JOIN jos_audittrail j2 ON ( j1.trackid != j2.trackid
AND j1.field = j2.field
AND j1.changedone < j2.changedone )
WHERE j1.operation = 'UPDATE'
AND j2.id IS NULL AND j1.field != 'lastvisitDate' AND j1.field != 'hits'

Thanks Pranav For the Support... :)

OM The Eternity