开发者

the sql generated in django

开发者 https://www.devze.com 2022-12-13 05:54 出处:网络
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

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

精彩评论

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