想要避免选择连接查询中的特定行...请参阅说明

发布于 2024-09-01 06:10:53 字数 820 浏览 4 评论 0原文

我有一个选择左连接查询,它向我显示最新更改的行(其时间)列名称(“字段”不应该相等)列名称(“trackid”不应该相等),以及列名称“操作应该”是“UPDATE”“,下面是我正在讨论的查询...

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

我得到的结果字段值为“lastvisitDate”或“hits”

现在在这里我不希望显示带有两个特定列的行值即“字段的值”,该值是“lastvisitDate”和“hits”

现在,如果我在上面的查询中附加条件 " AND j1.field != 'lastvistDate' AND j1.field != 'hits' " 然后我没有得到任何结果...

表结构是

jos_audittrail:

  1. id
  2. trackid
  3. 操作
  4. oldvalue
  5. newvalue
  6. table_name
  7. livechangedone
  8. (它的时间)

我希望我已经正确地给出了详细信息如果你仍然发现缺少一些东西我会尝试提供更多更好的方法...

请帮助我避免这两行与提到的“字段”值

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"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不…忘初心 2024-09-08 06:10:53

我以这种方式更改了我的选择查询,并以我需要的方式得到了结果,

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'

感谢 Pranav 的支持...:)

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... :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文