我在JOIN操作错误中出现语法错误(I have a Syntax error in JOIN operation error)
所以我在SELECT语句中尝试了几种变体,它一直告诉我“JOIN操作中的语法错误”或“无效的包围”或“FROM子句中的语法错误”
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/TravelJoansDB.accdb" SelectCommand="SELECT * FROM [Table2] INNER JOIN BlogEntryItems ON Table2.ID=BlogEntryItem.BlogID WHERE ([ID]=@ID)"> <SelectParameters> <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Decimal" /> </SelectParameters> </asp:AccessDataSource> <asp:DataList ID="DataList1" DataSourceID="AccessDataSource1" runat="server" ItemStyle-CssClass="picTableStyle" DataKeyField="BlogTitle"> <ItemStyle></ItemStyle> <ItemTemplate> <table> <tr> <td> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "PlaceImages/" + Eval("Image") %>' /><br /> <asp:Label ID="Label1" CssClass="picCaptionStyle" runat="server" Text='<%# Eval("Caption") %>' /> </td> </tr> <tr> <td> <asp:Label ID="Label4" class="picBodyText" runat="server" Text='<%# Eval("PicStory") %>' /> </td> </tr> </table> </ItemTemplate> </asp:DataList>
我正忙着去做。 正如您所看到的,我正在尝试将记录的ID传递到我的网站的主页上,并使用它来从“BlogEntryItem”表中提取记录并将其拉到我网站上的另一个页面中用这些项填充页面。 那有意义吗? 为什么我的JOIN不工作?
So I've tried several variants to my SELECT statement and it keeps telling me either "Syntax error in JOIN operation" or "Invalid bracketing" or "Syntax error in FROM clause"
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/TravelJoansDB.accdb" SelectCommand="SELECT * FROM [Table2] INNER JOIN BlogEntryItems ON Table2.ID=BlogEntryItem.BlogID WHERE ([ID]=@ID)"> <SelectParameters> <asp:QueryStringParameter Name="ID" QueryStringField="ID" Type="Decimal" /> </SelectParameters> </asp:AccessDataSource> <asp:DataList ID="DataList1" DataSourceID="AccessDataSource1" runat="server" ItemStyle-CssClass="picTableStyle" DataKeyField="BlogTitle"> <ItemStyle></ItemStyle> <ItemTemplate> <table> <tr> <td> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "PlaceImages/" + Eval("Image") %>' /><br /> <asp:Label ID="Label1" CssClass="picCaptionStyle" runat="server" Text='<%# Eval("Caption") %>' /> </td> </tr> <tr> <td> <asp:Label ID="Label4" class="picBodyText" runat="server" Text='<%# Eval("PicStory") %>' /> </td> </tr> </table> </ItemTemplate> </asp:DataList>
I'm having a rough go at it. As you can see, I'm trying to pass the ID of a record in that ends up on my home page for my website, and using that to pull records from the "BlogEntryItem" table and pulling it into another page on my website and populating the page with those items. Does that make sense? Why isn't my JOIN working?
原文:
最满意答案
这条线:
vars()[rate] = 'k' + str(i)
必须替换为:
vars()['k' + str(i)]=rate
The line:
vars()[rate] = 'k' + str(i)
has to be replaced by:
vars()['k' + str(i)]=rate
相关问答
更多-
Python:在for循环中将迭代变量的值添加到变量名称中(Python: Add value of iteration variable to variable name within for loop)[2023-05-19]
解决方案A(推荐): dfs = {} for i in l: dfs["a"+str(i)], dfs["b"+str(i)] = func(df[df.col3 == i]) ... 然后你可以使用这样的数据框: func2(dfs["a1"]) # dfs["a1"] represents func(df[df.col3 == i])'s first return. ... 解决方案B(不推荐) 如果你绝对想使用局部变量,你需要: for i in l: locals()["a" ... -
PEP8建议使用简短的变量名称,但实现这一点需要良好的编程卫生。 这里有一些建议可以缩短变量名称。 变量名称不是完整的描述符 首先,不要将变量名称视为其内容的完整描述符。 名称应该清楚,主要是为了能够跟踪他们来自哪里,只有这样他们才能提供一些有关内容。 # This is very descriptive, but we can infer that by looking at the expression students_with_grades_above_90 = filter(lambda s: s ...
-
是的,词典是解决方案: tables=["A","B","C"] vars = ["var1","var2","var3"] dict={} for val in tables: for val2 in vars: dict[val2+"_"+val] = foo dict[val2+"_"+val] = bar dict[val2+"_"+val] = foobar #and so 希望如果有帮助 Yup, dictionaries are solution: tables ...
-
Python:可以从字符串列表中创建新的变量名吗?(Python: Can one create new variable names from a list of strings? [duplicate])[2022-08-11]
为什么不用字符串作为键来构造字典呢? >>> class test(): def handy(self): a = raw_input('How many hands? ') d = { "hand" + str(i + 1) : self.do_something(i) for i in range(int(a)) } keys = d.keys() keys.sort() for x in keys: ... -
如何在python中迭代变量名并将值设置为它们?(How to iterate variable names in python and set the values to them?)[2022-10-10]
保留列表而不是解压缩。 geom = [row[0] for row in arcpy.da.SearchCursor(InFc, ["SHAPE@"])] geom[0].union(geom[1]) g= geom[2].union(geom[0]) with arcpy.da.InsertCursor(output, ["SHAPE@"]) as cur: for geo in geom: cur.insertRow((g,)) 你真的试图insertRow((g,))三次insertRow ... -
您可以通过动态对象和反射来完成此操作。 这只是有翼的代码,但如果您发送给我或主持解决方案,我可以为您解决。 dynamic someOject = IronPython.Hosting.Python.CreateEngine(); foreach (var property in someOject.GetType().GetProperties()) Console.WriteLine($"Property Name: {property.Name} - Property Value: {pr ...
-
如果你确实需要这个,你可以从globals()或locals()字典中获取变量及其值。 >>> list_0 = [0, 1, 2] >>> list_1 = [3, 4, 5, 6] >>> list_2 = [7, 8, 9] >>> [globals()["list_{}".format(i)] for i in range(3)] [[0, 1, 2], [3, 4, 5, 6], [7, 8, 9]] 但是,几乎可以肯定,最好将各个列表作为list_all一部分存储起来,然后将它们作为list_ ...
-
这条线: vars()[rate] = 'k' + str(i) 必须替换为: vars()['k' + str(i)]=rate The line: vars()[rate] = 'k' + str(i) has to be replaced by: vars()['k' + str(i)]=rate
-
我认为你应该使用** kwds而不是args。 * args是值,因此调用者不能使用变量发送它,而只是自己赋值。 my_object.my_method(1, 2, 3, "string") 如果你使用** kwds,你就会知道键值对。 I think you should use **kwds instead of args. *args are values, so the caller can send it not with the variable, but just value itself. ...
-
Python:如何测试潜在的变量名是否在命名空间中?(Python: how to test if potential variable names are in the namespace?)[2021-07-05]
可怕,但这应该工作: all_vars = locals().get('all_vars', []) horrid, but this should work: all_vars = locals().get('all_vars', [])