You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can't get a stored field from the joined table, e.g. here select * doesn't return surnames (smith, goldman):
MySQL [(none)]>droptableif exists people; droptableif 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 onpeople.surname_id=surname.id;
--------------droptable if exists people
--------------
Query OK, 0 rows affected (0.012 sec)
--------------droptable if exists surname
--------------
Query OK, 0 rows affected (0.026 sec)
--------------createtablepeople(name text, surname_id bigint)
--------------
Query OK, 0 rows affected (0.001 sec)
--------------createtablesurname(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 onpeople.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 inset (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.
The text was updated successfully, but these errors were encountered:
You can't get a stored field from the joined table, e.g. here
select *
doesn't return surnames (smith
,goldman
):Calling it explicitly doesn't help:
The task is to make it possible to select stored fields from the right table.
The text was updated successfully, but these errors were encountered: