子查询和like运算符 [英] Sub query and like operator

查看:85
本文介绍了子查询和like运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表并且在网格视图中找到与运算符和记录显示类似的记录

datagridview显示部分表记录但是他的coulumn名称为modalID,但是我输入了一个文本框modalname这个mathod解决方案< br $>


零件表

i have two table and find record with like operator and record show in grid view
datagridview show a part table record but his coulumn name modalID, but i have type a textbox modalname this mathod solution

part table

brand modalId partId partname qty mrp





模态表



modal table

modalId brandId modalname





我的尝试:





What I have tried:

select modalname from modal1 where modalId =(select modalId from partstock where modalname='')

推荐答案

你需要在你的两个表之间连接,在这个cas中可能是一个内部联接...像这样:

来自modal内部加入部分modal.modalid = part.modalid



可以在没有子查询的情况下引用模态名称。



此外,在示例中使用子查询将'='替换为'in'。
You need a join between your two tables, in this case probably an inner join...like this:
from modal inner join part on modal.modalid = part.modalid

The where can just reference the modalname then without a subquery.

Also, to use a subquery as in your example replace '=' with 'in'.


你需要学习

* SQL联接 [ ^ ];在这种情况下,您将使用内部联接

* SQL LIKE运算符 [ ^ ]



您正在谈论SQL查询,您已标记为SmartWatch。错误的标记。

您还应该提到您正在使用的数据库。
You need to learn
* SQL Joins[^]; in this case you will work with inner join
* SQL LIKE Operator[^]

You are talking about SQL query, you have tagged as SmartWatch. Wrong tagging.
You should also mention what database you are using.


这篇关于子查询和like运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆