sql = "update customers as c inner join customers as c1 on c.introduce_id = c1.orig_cust_id set c.referral_cust_id = c1.id where c.introduce_id is not null" ActiveRecord::Base.connection.execute(sql) #也可以搭配一個變數來接收回傳值 results = ActiveRecord::Base.connection.execute(sql)
沒有留言:
張貼留言