暂无 |

MySQL 标量子查询

标量子查询是指子查询返回的是单一值的标量,如一个数字或一个字符串,也是子查询中最简单的返回形式。

一个标量子查询的例子如下:

SELECT * FROM article WHERE uid = (SELECT uid FROM user WHERE status=1 ORDER BY uid DESC LIMIT 1)

在该例子中,子查询语句:

SELECT uid FROM user WHERE status = 1 ORDER BY uid DESC LIMIT 1

返回的是单一的数字(如 2),实际的查询语句为:

SELECT * FROM article WHERE uid = 2

1

java教程
php教程
php+mysql教程
ThinkPHP教程
MySQL
C语言
css
javascript
Django教程

发表评论

    评价:
    验证码: 点击我更换图片
    最新评论