我不明白此查询中 e.*
、at_firstname.value
的用法:
SELECT e.*
, at_firstname.value AS firstname
FROM customer_entity AS e
INNER
JOIN customer_entity_varchar AS at_firstname
ON (at_firstname.entity_id = e.entity_id)
AND (at_firstname.attribute_id = '5')
WHERE (e.entity_type_id = '1')
AND (at_firstname.value = 'sander')
ORDER
BY e.email ASC
最佳答案
你的意思可能是
SELECT e.*, at_firstname.value AS firstname
FROM `customer_entity` AS `e`
INNER JOIN at_firstname ON
at_firstname.entity_id = e.entity_id AND at_firstname.attribute_id = '5'
WHERE e.entity_type_id = '1' AND at_firstname.value = 'sander' ORDER BY e.email ASC
e 是 customer_entity 表的别名 (customer_entity
AS e
),因此 e.* 表示 customer_entity 表的所有列。
at_firstname.value 似乎是一个错误,因为连接条件只需要表名而不需要 table.column
无论如何,sintax at_firstname.value AS firstname 意味着 tablename.columnname 使用列的别名 firtsname 显示
否则,如果原始查询正确,则 at_firstname.value AS 名字 是数据库at_firstname和表值的表别名at_firstname(列名值)的别名
PS 在不需要时不要在条件周围使用无用的 ()
关于mysql - * 和 的含义。在MySql中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46129242/