比如说数据库中有一张student表,要想把id为1的学生成绩(score)加1则
update student set score=score+1 where id = 1
如果你不加where系统就不会知道你具体要更新哪条记录,而导致所有该表中score都增加1,当然,除非这就是你的本意。
您好,这样的:SELECT *
FROM `table` AS t1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM `table`)) AS id) AS t2
WHERE t1.id >= t2.id
ORDER BY t1.id ASC LIMIT 5
SELECT * FROM `table` where id>0 ORDER BY RAND() LIMIT 0,100
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)