询问

编程入门 行业动态 更新时间:2024-10-25 07:23:59
本文介绍了询问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

i在我尝试使用公共值从两个表中检索值时遇到问题。 ie table1有emp_id和name,table2有emp_id和prod .. i试图使用查询 选择名称,从table1 prod,table2 where table1.emp_id =''some value'' ; 问题是表2中存在数据冗余并使用不同的关键字我也得到了不需要的值。 ie。 select distinct name,prod from table1,table2 where table1.emp_id =''some value''; i得到了prod的所有值。 我应该使用什么样的查询表中的反向值以避免冗余和不需要的数据。

解决方案

试试这个:

展开 | 选择 | 换行 | 行号

为了避免JOIN中数据的冗余,你需要通过表名来限定字段名称。

感谢查询它的工作正常。 i面对当我试图知道特定emp_id销售的产品数量时出现问题 即 从t1,t2组t2.id选择t1.name,count(prod) ; 错误不是GROUP BY表达式。

hi, i faced a problem when i tried to retrive value from two table using a common value. ie table1 has emp_id and name,table2 has emp_id and prod.. i tried to use the query select name,prod from table1,table2 where table1.emp_id=''some value''; The problem was there was redundancy of data in table2 and using distinct key word also i got unwanted values. ie. select distinct name,prod from table1,table2 where table1.emp_id=''some value''; i got all the values of prod. what kind of query i should use to retrive value from both the table to avoid redundant and unwanted data.

解决方案

Try this:

Expand|Select|Wrap|Line Numbers

To avoid redundancy of data in JOIN, you need to qualify the field names by the table name.

Thanks for the query its work fine. i faced a problem when i tried to know the number of products sold by a particular emp_id ie select t1.name,count(prod) from t1,t2 group t2.id; The error was not a GROUP BY expression.

更多推荐

询问

本文发布于:2023-11-25 11:57:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629651.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!