查询选择在过去30分钟内插入的所有字段实际上选择了每一行

Basically this query should select all the fields inserted in the last 30 minutes, but it doesnt, it selects absolutely every row making my script output wrong data

SELECT count(*) FROM mytable 
WHERE `time` >= DATE_SUB(UTC_TIMESTAMP, INTERVAL 30 minute)

My time field stores the time in this kind of format 2011-06-08 22:32:03

The query works, but it selects every row, not the ones inserted in the last 30 minutes.

Add parentheses to your query - UTC_TIMESTAMP() or use NOW() - quite simpler for me.

Try

SELECT count(*) FROM mytable 
WHERE `time` >= DATE_SUB(NOW(), INTERVAL 30 minute)