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 NumbersTo 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.更多推荐
询问
发布评论