MySQL不选择具有给定ID的行 [英] MySQL not selecting row with given id

查看:42
本文介绍了MySQL不选择具有给定ID的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表,一个气候"表和一个有利作物"表.我想使用此查询为特定位置选择所有有利作物,但它只选择所有内容而不管指定的id"

I have two tables, a 'climates' table and a 'favourablecrops' table. I want to select all the favourable crops for a particular location using this query but it just selects everything regardless of the specified 'id'

SELECT tbl_climatic.location, tbl_favourablecrops.favCrop 
FROM tbl_climatic, 
     tbl_favourablecrops 
WHERE tbl_climatic._id=tbl_favourablecrops.location_id=0

请帮忙

推荐答案

使用标准 join 和适当的 where 条件:

Use a standard join with appropriate where criteria:

SELECT tbl_climatic.location, tbl_favourablecrops.favCrop 
FROM tbl_climatic join
     tbl_favourablecrops on tbl_climatic._id=tbl_favourablecrops.location_id
WHERE tbl_favourablecrops.location_id=0

这篇关于MySQL不选择具有给定ID的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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