将不同树中的两个表加入 phpmyadmin
Join two tables in different tree into phpmyadmin
我需要在两个表之间进行连接,其中一个在分组内。但是查询给了我一个错误,我不知道该怎么办。enter image description here
我必须加入 users_field_data.uid 和 user__field_apellidos.entity_id,但它给我错误。
我应该怎么做?
enter image description here
enter image description here
谢谢!
编辑:
Table users_field_data:
CREATE TABLE IF NOT EXISTS `user__field_apellidos` (
`bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
`deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'A boolean indicating whether this data item has been deleted',
`entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to',
`revision_id` int(10) unsigned NOT NULL COMMENT 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
`langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The language code for this data item.',
`delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
`field_apellidos_value` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Data storage for user field field_apellidos.';
ALTER TABLE `user__field_apellidos`
ADD PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`),
ADD KEY `bundle` (`bundle`),
ADD KEY `revision_id` (`revision_id`);
CREATE TABLE IF NOT EXISTS `users_field_data` (
`uid` int(10) unsigned NOT NULL,
`langcode` varchar(12) CHARACTER SET ascii NOT NULL,
`preferred_langcode` varchar(12) CHARACTER SET ascii DEFAULT NULL,
`preferred_admin_langcode` varchar(12) CHARACTER SET ascii DEFAULT NULL,
`name` varchar(60) NOT NULL,
`pass` varchar(255) DEFAULT NULL,
`mail` varchar(254) DEFAULT NULL,
`timezone` varchar(32) DEFAULT NULL,
`status` tinyint(4) DEFAULT NULL,
`created` int(11) NOT NULL,
`changed` int(11) DEFAULT NULL,
`access` int(11) NOT NULL,
`login` int(11) DEFAULT NULL,
`init` varchar(254) DEFAULT NULL,
`default_langcode` tinyint(4) NOT NULL,
`content_translation_source` varchar(12) CHARACTER SET ascii DEFAULT NULL,
`content_translation_outdated` tinyint(4) DEFAULT NULL,
`content_translation_uid` int(10) unsigned DEFAULT NULL COMMENT 'The ID of the target entity.',
`content_translation_status` tinyint(4) DEFAULT NULL,
`content_translation_created` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='The data table for user entities.';
ALTER TABLE `users_field_data`
ADD PRIMARY KEY (`uid`,`langcode`),
ADD UNIQUE KEY `user__name` (`name`,`langcode`),
ADD KEY `user__id__default_langcode__langcode` (`uid`,`default_langcode`,`langcode`),
ADD KEY `user_field__mail` (`mail`(191)),
ADD KEY `user_field__created` (`created`),
ADD KEY `user_field__access` (`access`),
ADD KEY `user_field__content_translation_uid__target_id` (`content_translation_uid`);
Table user__field_apellidos:
CREATE TABLE IF NOT EXISTS `user__field_apellidos` (
`bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance',
`deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'A boolean indicating whether this data item has been deleted',
`entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to',
`revision_id` int(10) unsigned NOT NULL COMMENT 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id',
`langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The language code for this data item.',
`delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields',
`field_apellidos_value` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Data storage for user field field_apellidos.';
ALTER TABLE `user__field_apellidos`
ADD PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`),
ADD KEY `bundle` (`bundle`),
ADD KEY `revision_id` (`revision_id`);
你错过了连接部分。尝试以下查询:
s`elect * from user__field_apellidos inner join users_field_data on entity_id = users_field_data.uid`
我需要在两个表之间进行连接,其中一个在分组内。但是查询给了我一个错误,我不知道该怎么办。enter image description here
我必须加入 users_field_data.uid 和 user__field_apellidos.entity_id,但它给我错误。
我应该怎么做?
enter image description here
enter image description here
谢谢!
编辑: Table users_field_data:
CREATE TABLE IF NOT EXISTS `user__field_apellidos` ( `bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', `deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'A boolean indicating whether this data item has been deleted', `entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to', `revision_id` int(10) unsigned NOT NULL COMMENT 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id', `langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The language code for this data item.', `delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', `field_apellidos_value` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Data storage for user field field_apellidos.'; ALTER TABLE `user__field_apellidos` ADD PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`), ADD KEY `bundle` (`bundle`), ADD KEY `revision_id` (`revision_id`);
CREATE TABLE IF NOT EXISTS `users_field_data` ( `uid` int(10) unsigned NOT NULL, `langcode` varchar(12) CHARACTER SET ascii NOT NULL, `preferred_langcode` varchar(12) CHARACTER SET ascii DEFAULT NULL, `preferred_admin_langcode` varchar(12) CHARACTER SET ascii DEFAULT NULL, `name` varchar(60) NOT NULL, `pass` varchar(255) DEFAULT NULL, `mail` varchar(254) DEFAULT NULL, `timezone` varchar(32) DEFAULT NULL, `status` tinyint(4) DEFAULT NULL, `created` int(11) NOT NULL, `changed` int(11) DEFAULT NULL, `access` int(11) NOT NULL, `login` int(11) DEFAULT NULL, `init` varchar(254) DEFAULT NULL, `default_langcode` tinyint(4) NOT NULL, `content_translation_source` varchar(12) CHARACTER SET ascii DEFAULT NULL, `content_translation_outdated` tinyint(4) DEFAULT NULL, `content_translation_uid` int(10) unsigned DEFAULT NULL COMMENT 'The ID of the target entity.', `content_translation_status` tinyint(4) DEFAULT NULL, `content_translation_created` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='The data table for user entities.'; ALTER TABLE `users_field_data` ADD PRIMARY KEY (`uid`,`langcode`), ADD UNIQUE KEY `user__name` (`name`,`langcode`), ADD KEY `user__id__default_langcode__langcode` (`uid`,`default_langcode`,`langcode`), ADD KEY `user_field__mail` (`mail`(191)), ADD KEY `user_field__created` (`created`), ADD KEY `user_field__access` (`access`), ADD KEY `user_field__content_translation_uid__target_id` (`content_translation_uid`);
Table user__field_apellidos: CREATE TABLE IF NOT EXISTS `user__field_apellidos` ( `bundle` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The field instance bundle to which this row belongs, used when deleting a field instance', `deleted` tinyint(4) NOT NULL DEFAULT '0' COMMENT 'A boolean indicating whether this data item has been deleted', `entity_id` int(10) unsigned NOT NULL COMMENT 'The entity id this data is attached to', `revision_id` int(10) unsigned NOT NULL COMMENT 'The entity revision id this data is attached to, which for an unversioned entity type is the same as the entity id', `langcode` varchar(32) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'The language code for this data item.', `delta` int(10) unsigned NOT NULL COMMENT 'The sequence number for this data item, used for multi-value fields', `field_apellidos_value` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Data storage for user field field_apellidos.'; ALTER TABLE `user__field_apellidos` ADD PRIMARY KEY (`entity_id`,`deleted`,`delta`,`langcode`), ADD KEY `bundle` (`bundle`), ADD KEY `revision_id` (`revision_id`);
你错过了连接部分。尝试以下查询:
s`elect * from user__field_apellidos inner join users_field_data on entity_id = users_field_data.uid`