English 中文(简体)
MySQL SlectT query syntax - not working as expected?
原标题:MySQL SELECT query syntax - not working as expected?
  • 时间:2011-09-05 02:48:53
  •  标签:
  • php
  • mysql

我似乎无法做到这一点。

基本上,我想做的是,将“代码”栏目“时间/代码”栏超过<代码>的日码的所有浏览量,而“代码”栏则低于<代码>上限_hits。

将第一部分投入工作就是一个问题,但第二部分似乎是问题,因为它在<条码>、>打下_counter时仍然有条块状。

Here s my code:

$query = "SELECT * FROM links WHERE timestamp >=  $timestamp  AND hit_counter >=  max_hits  AND overflow =  NO ";
$result = mysql_query($query);
$size = mysql_num_rows($result);

似乎把所有正确的条目退回到timestamp上,然而,在hit_counter超过max_hits/code>的情况下,仍继续选择行文。 (尽管它只选择了“>”;=大于或等于],而在逆文<代码>>=<= 回归无结果,即使数学上有效。)

我认为,也许我指的是<代码>max_hits是一种不正确的价值,因为我不理解为什么它首先工作?

我知道我的问题很少,因此,如果需要澄清,请:

任何答复/帮助都将受到高度赞赏。

<><>UPDATE:

我按照以下许多大答复更新了询问(删除了“顶级编码”栏,并修改了<代码>;>;=至<=,但仍然是不是由查询所包括的回归行。

http://pastebin.com/V4vXJr1w“rel=”

这里与我的表层结构链接:

最佳回答

我认为,如果你删除大字塔上的字句的话,它将发挥作用:

$query = "SELECT * FROM links WHERE timestamp >=  ".$timestamp."  AND hit_counter <= max_hits AND overflow =  NO ";

问题在于,你指的是大范围,而不是一栏。

问题回答
$query = "SELECT * FROM links WHERE timestamp >=  $timestamp  AND hit_counter >=  max_hits  AND overflow =  NO ";

如果最高点是一栏,你就必须失去引语。

$query = "SELECT * FROM links WHERE timestamp >=  $timestamp  AND hit_counter >= max_hits AND overflow =  NO ";

Two things look wrong to me at a glance.

  1. 如果你想要比较一栏而不是一栏,你不想引用一栏名称,那么我就认为,把你打的“面”一栏与“顶点”相比较。

  2. 也许我对你也有误解,但我认为,你比落后的迹象大了。 大致应当:

    * 摘自WHERE时stamp >链接;=$timestamp和点击_counter <max_hits和过量=NO。





相关问题
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 ...

热门标签