具有 OR 条件的 QUERY 函数 >查询表,选择 E,其中 C 包含 Cell1 *OR* Cell2 limit 1
我尝试在以下查询中使用 OR 运算符。
这个想法是,单元格将显示来自分支的里程。用户可以选择 C12 或 E12 处的分支,单元格将显示表中的里程。我的下一步是制作一个 if 语句,但我想知道是否有可能使其像这样工作
=iferror(query(BranchesHrsKms, "Select E where C matches'"&C12&"' or C matches'"&E12&"'limit 1",0),"")`
当前代码的作用:基本上只是运行这部分
C matches'"&E12&"'limit 1",0),"")
,但仅当 C12 中有内容时才运行。
任何指导表示赞赏
更新: 它可以与If和ISBLANK一起使用
=IF(ISBLANK(C16)=FALSE, iferror(query(BranchesHrsKms,
"Select E where C matches'"&C16&"' limit 1",0),""),
iferror(query(BranchesHrsKms, "Select E where C matches'"&E16&"' limit 1",0),""))
I am attempting to use OR operator in the following Query.
The idea is that the cell will display mileage from a branch. The user can select a branch at either C12 or E12, and the cell will display the mileage from the table. My next move would be to make an if statement but I'm wondering if its possible to make it work like this
=iferror(query(BranchesHrsKms, "Select E where C matches'"&C12&"' or C matches'"&E12&"'limit 1",0),"")`
What the current code does: Basically just runs this part
C matches'"&E12&"'limit 1",0),"")
But only when there is something in C12.
Any guidance appreciated
Update:
It can work with If and ISBLANK
=IF(ISBLANK(C16)=FALSE, iferror(query(BranchesHrsKms,
"Select E where C matches'"&C16&"' limit 1",0),""),
iferror(query(BranchesHrsKms, "Select E where C matches'"&E16&"' limit 1",0),""))
Copy of sheet to play with: https://docs.google.com/spreadsheets/d/1fn5xzWi47xcgnQiDk5v_t1UDtIF6gHKGB4WoblbT3-Y/edit#gid=686684908
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
更新:
try:
update:
limit
之前缺少空间There is a lack of space before
limit