问题列表 - 第35844页

SQL从另一个表中的另一列更新一列

我在此之前阅读了各种帖子.但它们似乎都不适合我.

正如标题所示,我正在尝试从另一个表中的列更新一列.我不记得以前有这个问题..

1.表:user_settings.contact_id,我想用contacts.id更新where (user_settings.account_id == contacts_account_id)

2.以前通过account_id将联系人链接到用户帐户.但是,现在我们要将联系人链接到user_settingsviacontacts.id

以下是我尝试过的一些例子,尽管它们都没有奏效.我会感兴趣的是A.)为什么他们不工作和B.)我该怎么办呢.

例A:

UPDATE user_settings
SET user_settings.contact_id = contacts.id 
FROM user_settings 
INNER JOIN contacts ON user_settings.account_id = contacts.account_id
Run Code Online (Sandbox Code Playgroud)

例B:

UPDATE (SELECT A.contact_id id1, B.id id2
  FROM user_settings A, contacts B
  WHERE user_settings.account_id = contacts.account_id)
SET id1 = id2
Run Code Online (Sandbox Code Playgroud)

例C:

UPDATE user_settings
SET user_settings.contact_id = (SELECT id
  FROM contacts
  WHERE (user_settings.account_id = contacts.account_id)
WHERE EXISTS ( user_settings.account_id = contacts.account_id )
Run Code Online (Sandbox Code Playgroud)

我觉得我的大脑只是关闭了我,并希望重新启动它的任何颠簸.谢谢 :)

mysql join sql-update

19
推荐指数
1
解决办法
5万
查看次数

绑定到ObservableCollection的WFP DataGrid ItemsSource不会更新超出第一次设置?

我通过DataGrid的"ItemSource"将WPF应用程序DataGrid绑定到ObservableCollection.最初DataGrid确实提出了标题和值,但是对ObservableCollection的升级没有反映出来?(即当我以编程方式返回并增加"Total"值时)我正在使用的ObservableCollection如下.

任何想法为什么以及如何使网格动态更新/绑定正确?

public class SummaryItem
{
    public string ProcessName { get; set; }
    public long Total { get; set; }
    public long Average { get; set; }

    public static SummaryItem ObservableCollectionSearch(ObservableCollection<SummaryItem> oc, string procName)
    {
        foreach (var summaryItem in oc)
        {
            if (summaryItem.ProcessName == procName) return summaryItem;
        }
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

编辑 - 或许一个附加问题是,在这种情况下,DataGrid是否不是我应该使用的控件来可视化什么是有效的内存表?也就是说,SummaryItem的observableCollection实际上是内存表.

.net c# wpf observablecollection

1
推荐指数
1
解决办法
7407
查看次数

正则表达式 - 包括字符串:java

我试图打印出与java中特定模式匹配的文件中的行.我正在使用Pattern类来执行此操作.

我试着将模式设为"[harry]",这样就可以打印掉每一行都有"哈里"的行.但模式总是评估为假.我的假设是我输入的正则表达式是一个字符串.

我的代码如下:

try {

      BufferedReader br = new BufferedReader(new FileReader("test.txt"));
      Pattern p = Pattern.compile("harry");
      String str = null;
      try {
        while((str = br.readLine())!=null){
          Matcher match = p.matcher(str);
          boolean b = match.matches();
          if(b){
            System.out.println(str);
          }
        }
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
Run Code Online (Sandbox Code Playgroud)

请帮忙.我不明白代码在哪里破解.我正在尝试不同的模式匹配,但这是正确的方法吗?

谢谢

java regex pattern-matching

3
推荐指数
1
解决办法
147
查看次数

工具常用于R中的程序

如果已经以不同的方式提出这个问题,我很抱歉,但是找不到任何想要的东西.

我真的从其他软件包(SPSS)进入R.当我了解真正可以做到的事情时,我意识到我需要额外的"工具".这让我想到了我的问题.

你有什么设置来开发R代码?在不久的将来,我无法看到自己在任何地方开发r包,但我确实看到自己想要有效地管理我的r项目,以及在LaTeX中创建报告和演示文稿.

对于上下文,我在Eclipse for Windows中开发我的R代码,但是我很难成功设置Latex/Sweave和Github插件.

最后,您使用Windows或其他东西开发代码吗?

非常感谢您提供的任何洞察力.

ide r

9
推荐指数
3
解决办法
1118
查看次数

如何在numpy中进行分散/聚集操作

让我说我有阵列:

a = array((1,2,3,4,5))
indices = array((1,1,1,1))
Run Code Online (Sandbox Code Playgroud)

我执行操作:

a[indices] += 1
Run Code Online (Sandbox Code Playgroud)

结果是

array([1, 3, 3, 4, 5])
Run Code Online (Sandbox Code Playgroud)

换句话说,重复的内容indices被忽略

如果我希望重复项不被忽略,导致:

array([1, 6, 3, 4, 5])
Run Code Online (Sandbox Code Playgroud)

我该怎么办呢?

上面的例子有点微不足道,接下来正是我想要做的事情:

def inflate(self,pressure):
    faceforces = pressure * cross(self.verts[self.faces[:,1]]-self.verts[self.faces[:,0]], self.verts[self.faces[:,2]]-self.verts[self.faces[:,0]])
    self.verts[self.faces[:,0]] += faceforces
    self.verts[self.faces[:,1]] += faceforces
    self.verts[self.faces[:,2]] += faceforces

def constrain_lengths(self):
    vectors = self.verts[self.constraints[:,1]] - self.verts[self.constraints[:,0]]
    lengths = sqrt(sum(square(vectors), axis=1))
    correction = 0.5 * (vectors.T * (1 - (self.restlengths / lengths))).T
    self.verts[self.constraints[:,0]] += correction
    self.verts[self.constraints[:,1]] -= correction

def compute_normals(self):
    facenormals = cross(self.verts[self.faces[:,1]]-self.verts[self.faces[:,0]], self.verts[self.faces[:,2]]-self.verts[self.faces[:,0]])
    self.normals.fill(0) …
Run Code Online (Sandbox Code Playgroud)

python numpy

5
推荐指数
2
解决办法
3609
查看次数

iPhone - 没有setURL保存URL:forKey:和NSURL

无论如何使用没有setURL的NSUserDefaults保存URL:forKey:仅适用于iOS 4.0及更高版本?

我使用fileURLWithPath在本地加载HTML文件,它从一个介绍页面开始,用户可以点击进入任何内容.目前,每次用户重新开始时,都会将默认值加载到intro.htm.我希望能够将他们当前页面保存到viewdiddissapear上的NSUserDefaults并在下次重新加载它,但除了setURL之外找不到任何解决方案:forKey:.那里的任何人都知道解决方案?

iphone nsurl save uiwebview nsuserdefaults

2
推荐指数
1
解决办法
2630
查看次数

如何在配置活动中强制更新?

我正在编写一个带有配置活动的小部件,在OK单击其按钮时调用以下方法:

private void ok()
{
    // ...Do Widget Configuration...

    // Force an update
    Context context = getApplicationContext();
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
    AppWidgetManager.getInstance(context).updateAppWidget(widget_id, views);

    // Return the expected result
    Intent result = new Intent();
    result.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widget_id);
    setResult(RESULT_OK, result);

    finish();
}
Run Code Online (Sandbox Code Playgroud)

这几乎是文档中的逐字记录. widget_id保存在活动期间挖出的小部件ID onCreate().

当我在主屏幕上放置小部件的实例时,我已经验证我得到了预期的事件序列:

  • onReceive()得到一个ACTION_APPWIDGET_ENABLED如果它是第一个.
  • onUpdate() 被调用(我在其中检测到未配置小部件并将某些内容绘制为默认操作).
  • 出现配置活动.
  • 当我按下时OK,ok()上面的方法被调用.

The method gets all the way through to the finish() and the configuration activity goes …

android android-widget

5
推荐指数
1
解决办法
2450
查看次数

在PHP中以编程方式创建子域

我在共享主机和添加域上.

我需要为我的网站的每个用户创建子域名,如果用户名是杰夫,那么他应该有一个网址jeff.mydomain.com.

如何使用PHP以编程方式创建它?

php

3
推荐指数
1
解决办法
3829
查看次数

表示Haskell中四面体数的序列

我一直想要学习一些Haskell,我知道它和类似的语言对各种无限列表都有很好的支持.那么,我怎样才能在Haskell中表示四面体数的序列,最好解释一下发生了什么?

0   0   0
1   1   1
2   3   4
3   6   10
4   10  20
5   15  35
6   21  56
7   28  84
8   36  120
Run Code Online (Sandbox Code Playgroud)

如果不清楚那里发生了什么,第二列是第一列的运行总计,第三列是第二列的运行总计.我更喜欢Haskell代码保留一些"运行总计"的方法,因为这是我想知道如何表达的概念.

haskell list

5
推荐指数
2
解决办法
552
查看次数

帮助Ruby Koans#6 - 遇到了什么异常?

我正试图通过Koans学习Ruby,但我坚持第6步.

这是代码:

def test_you_dont_get_null_pointer_errors_when_calling_methods_on_nil  
  # What happens when you call a method that doesn't exist.    
  # The following begin/rescue/end code block captures the exception and  
  # make some assertions about it.  

  begin
    nil.some_method_nil_doesnt_know_about
  rescue Exception => ex
    # What exception has been caught?
    assert_equal __, ex.class

    # What message was attached to the exception?
    # (HINT: replace __ with part of the error message.)
    assert_match(/__/, ex.message)
  end
end
Run Code Online (Sandbox Code Playgroud)

我知道我应该用错误消息"NoMethodError"替换__,但我似乎无法弄明白.

这是我运行"path_to_enlightenment.rb"时收到的错误消息:

The answers you seek...
  <"FILL ME IN"> expected but was …
Run Code Online (Sandbox Code Playgroud)

ruby exception

10
推荐指数
1
解决办法
7971
查看次数