SQL在其他表中给定时间戳后从记录中选择

时间:2019-01-31 12:27:09

标签: php html mysql sql database

我有2张桌子。 一个用于消息,另一个用于delete_chats。 如果有人删除了聊天,那么它应该在删除时间戳后仅显示新消息

请在您的答案中使用这些表/列的名称:

SELECT * FROM user_messages um

    LEFT JOIN (

SELECT *
FROM user_chats_deleted
GROUP BY timestamp Order by timestamp ASC Limit 1
)ud ON (um.chat_id = ud.chat_id and um.user_id = ud.user_id and ud.timestamp     < um.timestamp)

    where um.chat_id = '4' ORDER BY um.timestamp ASC

我的SQL代码:

{
"users": {
   "$uid": {
     "email": "mail@example.com",
           }
         }
"items": {
    "$uid":{
     "externalId": "val",
     "$itemId": {
           }
}

它显示消息,但不是我想要的:/

1 个答案:

答案 0 :(得分:0)

您可以尝试几个不同的查询,尽管它们都应该执行相同的操作:

control

更干净,更易读/易懂的SQL脚本:

make_deparse65 <- function() {
  deparse2 <- function (expr, width.cutoff = 60L, backtick = mode(expr) %in% 
    c("call", "expression", "(", "function"), 
    control = 65, nlines = -1L, .deparseOpts = identity) {}
  body(deparse2) <- body(deparse)
  deparse2
}

Run <- function() {
  deparse65 <- make_deparse65()
  deparse65(identity)
}

# test
Run()