【问题标题】:bulk insert using insert...select in sqlite?使用插入批量插入...在sqlite中选择?
【发布时间】:2013-08-27 01:12:50
【问题描述】:

我有一个应该接收消息的用户列表。他们在表中订阅。现在我想为这些用户中的每一个插入一条消息。我的查询是

insert into message(user, type, theId)
    select (select user from subscribe_message), @type, @id

目前它是空的。我收到错误message.user may not be NULL。它不应该不插入任何行吗?当我有不止一行时,它只插入第一行。我该怎么写才能将 0 插入到多行?

【问题讨论】:

    标签: sqlite bulkinsert


    【解决方案1】:

    试试这个

    INSERT INTO message ( user, type, theId )
    SELECT  subscribe_message.user, @type, @id
    FROM    subscribe_message
    

    【讨论】:

    • 这很有效,而且看起来比我原来的要好得多。谢谢(如果允许我会接受)
    猜你喜欢
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-23
    • 2019-09-18
    相关资源
    最近更新 更多