Ошибка 1060 sql

Why I get #1060 — Duplicate column name ‘id’

SELECT COUNT(*) FROM (SELECT * FROM `tips` `t` LEFT JOIN
tip_usage ON tip_usage.tip_id=t.id GROUP BY t.id) sq

OMG Ponies's user avatar

OMG Ponies

326k82 gold badges523 silver badges502 bronze badges

asked Jan 27, 2011 at 11:16

Pentium10's user avatar

Pentium10Pentium10

205k122 gold badges423 silver badges502 bronze badges

5

Probably because the * in select * selects two columns with the same name from tip_usage and tips.

answered Jan 27, 2011 at 11:21

Andomar's user avatar

1

Probably it’s because the inner select yields two columns with the name id. Since you are not using those columns, you can just change the select to:

SELECT COUNT(*) FROM (SELECT t.id FROM `tips` `t` 
LEFT JOIN tip_usage ON tip_usage.tip_id=t.id 
GROUP BY t.id) sq 

answered Jan 27, 2011 at 11:21

Klaus Byskov Pedersen's user avatar

0

Your query is equivalent to this:

SELECT  COUNT(DISTINCT id)
FROM    tips

, there is no need in a join.

Are you sure you didn’t want an INNER JOIN instead?

answered Jan 27, 2011 at 11:23

Quassnoi's user avatar

QuassnoiQuassnoi

414k91 gold badges617 silver badges614 bronze badges

Had the same problem, renaming into select clause saved me

SELECT people.id, vehicle.id ...

I renamed it with AS keyword

SELECT people.id AS person_id, vehicle.id ...

answered Jul 4, 2018 at 1:34

Pipo's user avatar

PipoPipo

4,68138 silver badges47 bronze badges

Why I get #1060 — Duplicate column name ‘id’

SELECT COUNT(*) FROM (SELECT * FROM `tips` `t` LEFT JOIN
tip_usage ON tip_usage.tip_id=t.id GROUP BY t.id) sq

OMG Ponies's user avatar

OMG Ponies

326k82 gold badges523 silver badges502 bronze badges

asked Jan 27, 2011 at 11:16

Pentium10's user avatar

Pentium10Pentium10

205k122 gold badges423 silver badges502 bronze badges

5

Probably because the * in select * selects two columns with the same name from tip_usage and tips.

answered Jan 27, 2011 at 11:21

Andomar's user avatar

1

Probably it’s because the inner select yields two columns with the name id. Since you are not using those columns, you can just change the select to:

SELECT COUNT(*) FROM (SELECT t.id FROM `tips` `t` 
LEFT JOIN tip_usage ON tip_usage.tip_id=t.id 
GROUP BY t.id) sq 

answered Jan 27, 2011 at 11:21

Klaus Byskov Pedersen's user avatar

0

Your query is equivalent to this:

SELECT  COUNT(DISTINCT id)
FROM    tips

, there is no need in a join.

Are you sure you didn’t want an INNER JOIN instead?

answered Jan 27, 2011 at 11:23

Quassnoi's user avatar

QuassnoiQuassnoi

414k91 gold badges617 silver badges614 bronze badges

Had the same problem, renaming into select clause saved me

SELECT people.id, vehicle.id ...

I renamed it with AS keyword

SELECT people.id AS person_id, vehicle.id ...

answered Jul 4, 2018 at 1:34

Pipo's user avatar

PipoPipo

4,68138 silver badges47 bronze badges

Ошибка под номером 1060, появляющаяся в MySQL при определенном SQL запросе к Базе Данных означает, что в таблицах БД уже существуют колонки таблиц, которые пытаются установить.

В Joomla эта ошибка появляется при попытке обновить или установить повторно, какое либо, расширение. Ошибка не сложная, и она означает, что в БД уже есть такая колонка, которую пытаются установить. Инсталлятор Joomla подробно расшифрует ее в информационной розовой строке.

Инсталлятор покажет, какой SQL запрос вызвал ошибку и покажет название колонки, которая дублируется.

Этот скриншот не относится к примеру в статье, но относиться к ошибке #1060

Error-SQL-DB-1060-foto3

Error-SQL-DB-1060-foto3

Исправление ошибки 1060 Error SQL DB

Для исправления ошибки авторизуемся в панели управления на своем сервере, входим в phpMyAdmin и открываем базу данных своего сайта.

Важно! Сделайте резервную копию базы данных. Кнопка «Экспорт», выбрать все таблицы, сжатие ZIP или gZIP. В случае ошибки можно восстановить БД (кнопка «Импорт»).

Для дополнительной проверки инсталлятора Joomla делаем в базу данных запрос, который привел к ошибке и вы видите его в информационной строке инсталлятора.

Error-SQL-DB-1060-foto1

Error-SQL-DB-1060-foto1

Получаем ответ, от MySQL. В моем примере я обновлял компонент ARTIO JoomSEF. Запрос вы видите на фото, как в принципе и ответ MySQL: #1060-dublicate column name ‘metecustom’. В запросе видим название таблицы: sefurls. В ответе видим, что колонка ‘metecustom’ уже есть в базе данных.

Дальше не сложно. Открываете таблицу sefurls (кликаете по названию в левом списке таблиц), ищите колонку ‘metecustom’. Это текстовая колонка без данных. Далее, удаляем эту колонку, нажав на красный крест в ее строке. Или выделяем чекбокс колонки и нажимаем кнопку «Удалить» в фильтре «Действия» внизу таблицы.

Error-SQL-DB-1060-foto2

Error-SQL-DB-1060-foto2

Возвращаемся в административную часть сайта и устанавливаем расширение заново. Должно все получиться.

Причина ошибки MySQL #1060

Откуда появляется ошибка дублирования колонок. В моем примере эта ошибка появилась из-за того, что я в ручную переносил базу данных ARTIO JoomSEF при обновлении Joomla1.5 до Joomla2.5. В работе это не мешало, а вот при обновлении расширения проявилось. В любом случае, Ошибка MySQL, #1060 Error SQL DB на CMS Joomla не сложная, просто внимательно читайте сообщение JInstaller (инсталлятора Joomla).

©Joomla-abc.ru

Другие ошибки Joomla

 

Что такое логи сайта

Что такое логи сайта

Что такое логи сайта

Логи это специальные текстовые файлы с записями всех обращений к сайту. Каж…

I have 2 tables, advertisers and campaigns. Both have more fields I care to list and both have a primary key «id». I’d like to create a view without having to enter all fields manually using * instead. I keep getting the «duplicate column» error. Is it possible to do this via * at all or is my only option to enter all column names and setting aliases for the IDs?

  CREATE VIEW VIEW_CAMPAIGNS AS 

  SELECT *, 
      advertisers.id as adv_id,
      campaigns.id as camp_id

  FROM  campaigns, advertisers
  WHERE advertisers.id = advertiser_id

Still returns #1060 — Duplicate column name ‘id’

asked Feb 18, 2014 at 23:10

Rid Iculous's user avatar

5

You can do this in MySQL (and other standard databases) by using the using form of the join instead of the onclause.

Unfortunately, you can do that here because the join keys have different ids in the two tables. If they had the same name, you would just do:

CREATE VIEW VIEW_CAMPAIGNS AS
SELECT *,
FROM campaigns c join
advertisers a
using (advertisers_id);

The nearest you can do is to choose the bigger table, use * for that and then list all the columns for the other table.

Or, better yet, just use the information_schame.columns table to generate the column names. Something like:

select (case when column_name = 'id' and table_name = 'campaigns' then `c.campaign_id`
             when column_name = 'id' and table_name = 'advertisers' then 'a.advertiser_id'
             when table_name = 'campaigns' then concat('c.', column_name)
             when table_name = 'advertisers' then concat('a.', column_name)
        end) as column_name
from information_schema.columns
where table_name in ('campaigns, 'advertisers')

answered Feb 19, 2014 at 3:32

Gordon Linoff's user avatar

Gordon LinoffGordon Linoff

1.2m58 gold badges647 silver badges791 bronze badges

1

you can do it that why

  CREATE VIEW VIEW_CAMPAIGNS AS 

  SELECT u.id AS u_id
       ....
  , u2.id AS u2_id

  FROM  campaigns u
  INNER JOIN advertisers u2
  ON u.id = u2.advertiser_id

then its automatically columns are differentited .

  • for performance : better use columns which you need only and not using * . to not select all columns (40) every time.

EDIT:

Aliases can be used for individual columns.

You’ll have to alias each column instead

check this answer

Community's user avatar

answered Feb 18, 2014 at 23:26

echo_Me's user avatar

echo_Meecho_Me

37.1k5 gold badges58 silver badges78 bronze badges

1

Why I get #1060 — Duplicate column name ‘id’

SELECT COUNT(*) FROM (SELECT * FROM `tips` `t` LEFT JOIN
tip_usage ON tip_usage.tip_id=t.id GROUP BY t.id) sq

OMG Ponies's user avatar

OMG Ponies

324k80 gold badges520 silver badges499 bronze badges

asked Jan 27, 2011 at 11:16

Pentium10's user avatar

Pentium10Pentium10

204k122 gold badges422 silver badges500 bronze badges

5

Probably because the * in select * selects two columns with the same name from tip_usage and tips.

answered Jan 27, 2011 at 11:21

Andomar's user avatar

1

Probably it’s because the inner select yields two columns with the name id. Since you are not using those columns, you can just change the select to:

SELECT COUNT(*) FROM (SELECT t.id FROM `tips` `t` 
LEFT JOIN tip_usage ON tip_usage.tip_id=t.id 
GROUP BY t.id) sq 

answered Jan 27, 2011 at 11:21

Klaus Byskov Pedersen's user avatar

0

Your query is equivalent to this:

SELECT  COUNT(DISTINCT id)
FROM    tips

, there is no need in a join.

Are you sure you didn’t want an INNER JOIN instead?

answered Jan 27, 2011 at 11:23

Quassnoi's user avatar

QuassnoiQuassnoi

411k91 gold badges613 silver badges613 bronze badges

Had the same problem, renaming into select clause saved me

SELECT people.id, vehicle.id ...

I renamed it with AS keyword

SELECT people.id AS person_id, vehicle.id ...

answered Jul 4, 2018 at 1:34

Pipo's user avatar

PipoPipo

4,57338 silver badges47 bronze badges

От автора

Ошибка под номером 1060, появляющаяся в MySQL при определенном SQL запросе к Базе Данных означает, что в таблицах БД уже существуют колонки таблиц, которые пытаются установить.

В Joomla эта ошибка появляется при попытке обновить или установить повторно, какое либо, расширение. Ошибка не сложная, и она означает, что в БД уже есть такая колонка, которую пытаются установить. Инсталлятор Joomla подробно расшифрует ее в информационной розовой строке.

Инсталлятор покажет, какой SQL запрос вызвал ошибку и покажет название колонки, которая дублируется.

Этот скриншот не относится к примеру в статье, но относиться к ошибке #1060

Error-SQL-DB-1060-foto3

Исправление ошибки 1060 Error SQL DB

Для исправления ошибки авторизуемся в панели управления на своем сервере, входим в phpMyAdmin и открываем базу данных своего сайта.

Важно! Сделайте резервную копию базы данных. Кнопка «Экспорт», выбрать все таблицы, сжатие ZIP или gZIP. В случае ошибки можно восстановить БД (кнопка «Импорт»).

Для дополнительной проверки инсталлятора Joomla делаем в базу данных запрос, который привел к ошибке и который вы видите в информационной строке инсталлятора.

Error-SQL-DB-1060-foto1

Получаем ответ, от MySQL. В моем примере я обновлял компонент ARTIO JoomSEF. Запрос вы видите на фото, как в принципе и ответ MySQL: #1060-dublicate column name ‘metecustom’. В запросе видим название таблицы: sefurls. В ответе видим, что колонка ‘metecustom’ уже есть в базе данных.

Дальше не сложно. Открываете таблицу sefurls (кликаете по названию в левом списке таблиц), ищите колонку ‘metecustom’. Это текстовая колонка без данных. Далее, удаляем эту колонку, нажав на красный крест в ее строке. Или выделяем чекбокс колонки и нажимаем кнопку «Удалить» в фильтре «Действия» внизу таблицы.

Error-SQL-DB-1060-foto2

Возвращаемся в административную часть сайта и устанавливаем расширение заново. Должно все получиться.

Откуда появляется ошибка дублирования колонок. В моем примере эта ошибка появилась из-за того, что я в ручную переносил базу данных ARTIO JoomSEF при обновлении Joomla1.5 до Joomla2.5. В работе это не мешало, а вот при обновлении расширения проявилось. В любом случае, Ошибка MySQL, #1060 Error SQL DB на CMS Joomla не сложная, просто внимательно читайте сообщение JInstaller (инсталлятора Joomla).

©Joomla-abc.ru

Другие ошибки Joomla

You can do this in MySQL (and other standard databases) by using the using form of the join instead of the onclause.

Unfortunately, you can do that here because the join keys have different ids in the two tables. If they had the same name, you would just do:

CREATE VIEW VIEW_CAMPAIGNS AS
SELECT *,
FROM campaigns c join
advertisers a
using (advertisers_id);

The nearest you can do is to choose the bigger table, use * for that and then list all the columns for the other table.

Or, better yet, just use the information_schame.columns table to generate the column names. Something like:

select (case when column_name = 'id' and table_name = 'campaigns' then `c.campaign_id`
             when column_name = 'id' and table_name = 'advertisers' then 'a.advertiser_id'
             when table_name = 'campaigns' then concat('c.', column_name)
             when table_name = 'advertisers' then concat('a.', column_name)
        end) as column_name
from information_schema.columns
where table_name in ('campaigns, 'advertisers')

делаю запрос

SELECT COUNT(*) 
FROM (
    SELECT 
    `fl_serial`.`id`,
    `fl_serial`.`name_serial`,
    `fl_serial`.`slug_serial`,
    `fl_serial`.`description_serial`,
    `fl_serial`.`nesting`,
    `fl_serial`.`year`,
    `fl_serial`.`country_title`,
    `fl_film`.`id`,
    `fl_film`.`name_film`,
    `fl_film`.`slug_film`,
    `fl_film`.`description_film`,
    `fl_film`.`nesting`,
    `fl_film`.`year`,
    `fl_film`.`country_title`,
    `fl_mfilm`.`id`,
    `fl_mfilm`.`name_mfilm`,
    `fl_mfilm`.`slug_mfilm`,
    `fl_mfilm`.`description_mfilm`,
    `fl_mfilm`.`nesting`,
    `fl_mfilm`.`year`,
    `fl_mfilm`.`country_title`,
    `fl_cat_serial`.`id`,
        COALESCE(`fl_serial`.`id`, `fl_film`.`id`, `fl_mfilm`.`id` ) AS `ids`,
        COALESCE(`fl_serial`.`name_serial`, `fl_film`.`name_film`, `fl_mfilm`.`name_mfilm` ) AS `name`,
        COALESCE(`fl_serial`.`slug_serial`, `fl_film`.`slug_film`, `fl_mfilm`.`slug_mfilm`) AS `slug`,
        COALESCE(`fl_serial`.`description_serial`, `fl_film`.`description_film`, `fl_mfilm`.`description_mfilm`) AS `description`,
        COALESCE(`fl_serial`.`nesting`, `fl_film`.`nesting`, `fl_mfilm`.`nesting` ) AS `nesting`,
        COALESCE(`fl_serial`.`year`, `fl_film`.`year`, `fl_mfilm`.`year` ) AS `years`,
        COALESCE(`fl_serial`.`country_title`, `fl_film`.`country_title`, `fl_mfilm`.`country_title` ) AS `country_title` 
        FROM `fl_cat_serial` 
        LEFT JOIN `fl_serial` ON fl_cat_serial.id_serial = fl_serial.id 
        LEFT JOIN `fl_film` ON fl_cat_serial.id_film = fl_film.id 
        LEFT JOIN `fl_mfilm` ON fl_cat_serial.id_mfilm = fl_mfilm.id 
        WHERE `fl_cat_serial`.`id_cat`=12 
        GROUP BY `ids`) `c`

получаю следующую ошибку

#1060 — Duplicate column name ‘id’

почему ? И как исправить ?

        • ERROR 1060
        • Dos client garbled problem
        • ERROR 1395 :Can not delete from join view
        • column ‘**’ in field list is ambiguous

ERROR 1060

1. Error description:
Duplicate column name ‘xxx’;
Duplicate field xxx. When adding a database field, adding an existing field in the database will report this error
2. Example demonstration:

# The table structure is as follows
select * from dept;
+--------+----------+
| deptId | deptName |
+--------+----------+
 | 1 | Development Department |
 | 2 | Test Department |
 | 3 | UI Department |
| 4 | Game Department |
+--------+----------+

 #Add a field named deptId on the original table structure
alter table dept add deptId bigint(20);
 #Error, suggesting that the deptId field is repeated
ERROR 1060 (42S21): Duplicate column name 'deptId'

Dos client garbled problem

1. Problem description:
When using cmd to open MySQL on Windows, garbled characters appear. After checking the database encoding, the encoding is utf8; the reason for this error is because the operating system is a Chinese operating system, and the default character set is GB2312 , But the character encoding used when displaying Chinese in the MySQL client output window is utf8
这里写图片描述
这里写图片描述

View the character encoding used in the output window

 show variables like 'char%';

这里写图片描述

2. Solution
Change the encoding of the output console to gb2312

set character_set_results=gb2312;

这里写图片描述

Display after changing encoding
这里写图片描述

Note: If you use the mysql client tool, this error will not occur

ERROR 1395 :Can not delete from join view

1. Error description
Multiple tables use internal connections to generate a view, try to delete a record from this view, this error occurs

#Create a view
create view view_emp_all 
as 
select d.deptId,d.deptName,e.empName,e.salary,e.phone 
from 
dept d inner join emp e on d.deptId=e.deptId;

 #View view
select * from view_emp_all;
+--------+----------+---------+--------+-------+
| deptId | deptName | empName | salary | phone |
+--------+----------+---------+--------+-------+
 | 1 | Development Department | Zhang San | 10000 | 111 |
 | 1 | Development Department | Li Si | 9999 | 112 |
 | 2 | Test Department | Wang Wu | 8888 | 113 |
3 | UI Department | Zhao Liu | 7777 | 114 |
+--------+----------+---------+--------+-------+

Delete the record with deptId=1 in view_emp_all

delete from view_emp_all where deptId=1;
ERROR 1395 (HY000): Can not delete from join view 'test55.view_emp_all'

2. Solution
The first case: check whether the view can be modified, only the view can be modified to delete

#Check if the view is updatable
SELECT IS_UPDATABLE FROM information_schema.views WHERE TABLE_NAME = 'view_emp_all';
 #Check whether all views in the test55 database can be updated
SELECT table_name,is_updatable FROM information_schema.views WHERE table_schema = 'test55';

+--------------+
| IS_UPDATABLE |
+--------------+
| YES          |
+--------------+ 

The second case: the view created by the connection query, the delete operation may not only change the records in a table, the database will not allow this to ensure the integrity of the data, so you can only step by step from the table that builds this view Delete the record to delete the view record to be deleted

column ‘**’ in field list is ambiguous

1. Description:
When querying the contingency table, it is not specified which table the field belongs to, resulting in ambiguity
2. Examples

The first table contains the studentId field

select studentId,studentName from student;
+-----------+-------------+
| studentId | studentName |
+-----------+-------------+
 | 16046122 | Zhang San |
 | 16046124 | Li Si |
 | 16045122 | Wang Wu |
| 16045123 | Zhao Liu |
+-----------+-------------+

The second table also contains the studentId field

select studentId from truant;
+-----------+
| studentId |
+-----------+
| 16046122  |
| 16046124  |
+-----------+

这里写图片描述
You can see that the table to which the student belongs was not specified during the query, and ambiguity occurred at this time
Solution, declare which table the field belongs to

select student.studentId,studentName from student inner join truant where student.studentId=truant.studentId;
+-----------+-------------+
| studentId | studentName |
+-----------+-------------+
 | 16046122 | Zhang San |
| 16046124 | Li Si |
+-----------+-------------+

Понравилась статья? Поделить с друзьями:
  • Ошибка 108 тесо
  • Ошибка 1060 mysql
  • Ошибка 1067 при запуске службы eou
  • Ошибка 108 сбербанк
  • Ошибка 1067 при запуске валоранта