Tuesday, 15 May 2012

php - MySQL ORDER BY combined with LIMIT 1 returns empty result -



php - MySQL ORDER BY combined with LIMIT 1 returns empty result -

we have script automatically inserts hash value out of pool article if meet conditions. extension doing programmed several years ago , worked far. stopped working , nobody knows why. after long time of debugging found error in sql statement.

the generated statement looked this:

select `hash` `table` `is_used` =0 order `uid` limit 1

if remove "order uid", works again. know why happened out of blue. hoster said there no changes/updates made on systems side , checked related files, none of changed within lastly year.

about system. typo3 4.5.2 php version 5.3.8-1~dotdeb.1 mysql version 5.1.57

thanks in advance

edit: sorry confusion. "stopped working" meant 1 day no hashes inserted articles. when execute statement order by, i'm getting 1 empty row result. uid column still exists. there no changes on system, including database , tables. i've attached image table construction , both query results on right (well, it's not attached, since need more reputation attach it).

to clarify question again: query worked before , returned hash. works when remove order , know how happen, since i'm curious , may help me future errors. http://i.stack.imgur.com/dpip4.png

p.s.: i've edited table name, don't scared ;)

looking @ screen print, whether have order clause or not row beingness returned.

you using limit 1 bring single record. when have order clause in place bring record lowest uid. happens has blank hash value (possibly set in error @ point).

i tempted check hash not blank in clause.

select `hash` `table` `is_used` =0 , `hash` != '' order `uid` limit 1

php mysql typo3

No comments:

Post a Comment