通过计算从 SELECT 更新

发布于 2024-12-09 11:15:00 字数 660 浏览 0 评论 0原文

我正在尝试按照 这个 SO 线程

它不起作用。我想知道是否是因为我在执行计算时需要不同的 UPDATE...SELECT 结构。

我尝试过以下各种版本:

        UPDATE tbl_usertime uat
            SET uat.delay_qual = (TIMESTAMPDIFF(MINUTE, uat.view_date, '2011-10-11 15:22:25') > adt.delay), 
            freq_qual = (adt.frequency > uat.imps_today)
        FROM tbl_timing adt
        JOIN tbl_usertime uat 
            ON uat.ad_id = adt.ad_id;

...但它返回“SQL 语法错误...靠近 'FROM tbl_timing adt JOIN tbl_usertime uat”

有什么想法吗? 谢谢!

I'm trying to do an UPDATE from a SELECT following the format given by this SO thread

It's not working. I'm wondering if it's because I need a different UPDATE...SELECT structure when performing calculations.

I've tried various versions of the following:

        UPDATE tbl_usertime uat
            SET uat.delay_qual = (TIMESTAMPDIFF(MINUTE, uat.view_date, '2011-10-11 15:22:25') > adt.delay), 
            freq_qual = (adt.frequency > uat.imps_today)
        FROM tbl_timing adt
        JOIN tbl_usertime uat 
            ON uat.ad_id = adt.ad_id;

...but it returns 'error in SQL syntax...near 'FROM tbl_timing adt JOIN tbl_usertime uat'

Any ideas?
Thanks!

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

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

发布评论

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

评论(2

夜雨飘雪 2024-12-16 11:15:00

MySQL 语法有点不同,试试这个:

update tbl_usertime uat join tbl_timing adt on uat.ad_id=adt.ad_id set
    uat.delay_qual = (TIMESTAMPDIFF(MINUTE, uat.view_date, '2011-10-11 15:22:25') > adt.delay), 
        freq_qual = (adt.frequency > uat.imps_today)

The MySQL syntax is a little bit different, try this:

update tbl_usertime uat join tbl_timing adt on uat.ad_id=adt.ad_id set
    uat.delay_qual = (TIMESTAMPDIFF(MINUTE, uat.view_date, '2011-10-11 15:22:25') > adt.delay), 
        freq_qual = (adt.frequency > uat.imps_today)
⊕婉儿 2024-12-16 11:15:00

我不确定它是否有效,但阅读 MySQL 文档给我的印象可能是有效的:

UPDATE tbl_usertime join tbl_timing
SET tbl_usertime.delay_qual = (TIMESTAMPDIFF(MINUTE, tbl_usertime.view_date, '2011-10-11 15:22:25') > tbl_timing.delay), 
    freq_qual = (tbl_timing.frequency > tbl_usertime.imps_today)
where 
tbl_usertime.ad_id = tbl_timing.ad_id;

I am not sure it will work, but reading MySQL documentation gives me the impression that may be valid:

UPDATE tbl_usertime join tbl_timing
SET tbl_usertime.delay_qual = (TIMESTAMPDIFF(MINUTE, tbl_usertime.view_date, '2011-10-11 15:22:25') > tbl_timing.delay), 
    freq_qual = (tbl_timing.frequency > tbl_usertime.imps_today)
where 
tbl_usertime.ad_id = tbl_timing.ad_id;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文