dongyanju0945 2015-10-18 16:46
浏览 12
已采纳

只允许三个新闻

I am creating a news feed and am trying to allow three news updates (per person) at a time.

The structure of the MYSQL db is as follows:

username|update1|update2|update3

bill     foo     bar     baz

I am wondering how I can make it so that when bill posts a new news update:

  • the value of update3 would be removed
  • the value from update2 would be moved to update3
  • the value from update1 would be moved to update2
  • and the new news update would be placed at update1

Would this be possible in simply a MYSQL query or would I have to use PHP to do this?

  • 写回答

2条回答 默认 最新

  • douzhun8615 2015-10-18 16:48
    关注

    Try this:

    UPDATE table
        SET update3 = update2,
            update2 = update1,
            update1 = {$your_input} 
        WHERE your_filter = your_condition
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分