开发者

the sql generated in django

when i print the sql generated in connection.queries:

i found some sql like this:

SELEC开发者_开发百科T (1) AS `a` FROM `auth_user` WHERE `auth_user`.`id` = 2 

what's that mean?


It's used to check if that row exists, without actually fetching any data (constructed by django.db.models.sql.query.BaseQuery.has_results, called by e.g. QuerySet.exists).


Selects value '1' under the alias (column name) 'a' for each entry of table (or view) 'auth_user' if condition auth_user.id=2 holds.

In other words: it returns a single field ('a') with the value '1' for all users with id=2

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜