English 中文(简体)
为什么我的SQL会加入一套通知?
原标题:Why is a MySQL join returning a circular set?
  • 时间:2012-05-19 00:09:07
  •  标签:
  • mysql
  • join

让我说,我有两个表格:

www.un.org/Depts/DGACM/index_spanish.htm

1,a
2,b
3,c

www.un.org/Depts/DGACM/index_chinese.htm

1,alpha
2,beta
3,gamma

Ok so I execute the query select * from english limit 1,5 and i get:

2,b
3,c

这是我所期望的。 现在,我尝试select english.id,english.letter,greek.letter from english会加入关于贪 gr的贪 gr。 id asc limit 1,

2,b,beta
3,c,gama
1,a,alpha
2,b,beta
3,c,gama

www.un.org/spanish/ecosoc 是什么? 我也期望,这一次问候会工作:

select english.id,english.letter,greek.letter from english participation greek on greek.id=english.id group by english. id Order by english. id asc limit 1,

2,b,beta
3,c,gama

www.un.org/spanish/ecosoc 因此,这里的伤痕如何? 为什么我需要将“<代码>小组”改为“我期望”的行为?

最佳回答

或许,您的<代码>greek表格中有重复浏览。

当我在MySQL.5.20上尝试时,它做了一些细微的工作:

这方面的一个例子是,我故意在<条码>greek上插入重复浏览。 http://sqlfiddle.com/#!2/3b548/1

问题回答

LMIT适用于整个问题。 如果你想要限制特定表格,则首先适用限制。

select english.id,english.letter,greek.letter 
from (select * from english limit 1,5) as english
join greek on greek.id=english.id

并且,除非是任意的,否则,你应当根据《京都议定书》条款作出更正。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签