Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JOIN: stored fields from the joined table #1915

Closed
sanikolaev opened this issue Mar 6, 2024 · 1 comment
Closed

JOIN: stored fields from the joined table #1915

sanikolaev opened this issue Mar 6, 2024 · 1 comment
Assignees
Labels

Comments

@sanikolaev
Copy link
Collaborator

You can't get a stored field from the joined table, e.g. here select * doesn't return surnames (smith, goldman):

MySQL [(none)]> drop table if exists people; drop table if exists surname; create table people(name text, surname_id bigint); create table surname(surname text); insert into people values (1, 'john', 1), (2, 'mary', 1), (3, 'bill', 2),(4, 'matt', 3); insert into surname values(1, 'smith'),(2, 'goldman'); select * from people left join surname on people.surname_id = surname.id;
--------------
drop table if exists people
--------------

Query OK, 0 rows affected (0.012 sec)

--------------
drop table if exists surname
--------------

Query OK, 0 rows affected (0.026 sec)

--------------
create table people(name text, surname_id bigint)
--------------

Query OK, 0 rows affected (0.001 sec)

--------------
create table surname(surname text)
--------------

Query OK, 0 rows affected (0.001 sec)

--------------
insert into people values (1, 'john', 1), (2, 'mary', 1), (3, 'bill', 2),(4, 'matt', 3)
--------------

Query OK, 4 rows affected (0.000 sec)

--------------
insert into surname values(1, 'smith'),(2, 'goldman')
--------------

Query OK, 2 rows affected (0.000 sec)

--------------
select * from people left join surname on people.surname_id = surname.id
--------------

+------+------+------------+------------+
| id   | name | surname_id | surname.id |
+------+------+------------+------------+
|    1 | john |          1 |          1 |
|    2 | mary |          1 |          1 |
|    3 | bill |          2 |          2 |
|    4 | matt |       NULL |          0 |
+------+------+------------+------------+
4 rows in set (0.000 sec)

Calling it explicitly doesn't help:

MySQL [(none)]> select surname.surname from people left join surname on people.surname_id = surname.id;
--------------
select surname.surname from people left join surname on people.surname_id = surname.id
--------------

ERROR 1064 (42000): table people: parse error: unknown attribute 'surname.surname'

The task is to make it possible to select stored fields from the right table.

@glookka
Copy link
Contributor

glookka commented Mar 12, 2024

Done in 8db8be0

@glookka glookka closed this as completed Mar 12, 2024
@sanikolaev sanikolaev added the rel::upcoming Upcoming release label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants