从三个表中获取值并将所有三个值与单个表进行比较

时间:2013-05-21 10:54:55

标签: mysql

我在创建mysql查询时遇到问题。有点复杂,但我会尽力说清楚。我有四个表,如:

  • 1)farmer_details
  • 2)disrtrictlist
  • 3)阻止
  • 4)村。

我有三个已知值

  

disrict(id),block(id),village(id)from table disrtrictlist blocks village

首先,我想从这三个表中获取这三个字段,然后我想在farmer_details表中找到这三个值。如果您理解并有任何建议请提供帮助。

我写这些查询,但它对我不起作用: -

select 
    farmer_name,
    father_name,
    district,
    centre,
    land,
    farmer_details.village,
    mobile 
from farmer_details
    ,disrtrictlist
    ,blocks
    ,village 
WHERE disrtrictlist.name_id  LIKE '6' 
    AND ( blocks.id  LIKE '53' and village.id LIKE '2')

0 个答案:

没有答案