Storing SQL queries with multiple rows into a struct

agolangf · · 362 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I&#39;m currently writing a program to query a database, store the results (most likely insert them into a new table) and then compare results I.e., I&#39;ll perform a query and store results, then requery an hour later and compare the results from an hour ago to check for changes.</p> <p>I built structs for the tables such that:</p> <pre><code>type table1 struct { id int col1 string col2 time.Time } type table2 struct{ id int col1 string col2 time.Time } </code></pre> <p>I&#39;m struggling with how to store the multiple row values into a struct in the simplest manner, then call it back and compare a field. I&#39;ll be comparing a specific field such as if t1.col1 == t2.col1 then check to see if this other field matches.</p> <p>I&#39;m not exactly sure how to store multiple rows into my struct easily though and then write it into a new table. So far I&#39;ve figured that I&#39;d use a slice of struct but I&#39;m a little confused as to where to go from there/how to scan it in properly. I hope this is elaborated clearly. Thanks! </p>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

362 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传