https://antibiotiqueaugmentin.com/surdosage-augmentin-bebe/
× Welcome to the ToolsJX forum!


Duplicate column name 'id'

  • Romuba
  • Romuba's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 1 week ago #3515

I am preparing to use Tables JX and want to create a view in my DB. I use the following:

CREATE VIEW SwimView AS

SELECT *FROM events_eb_events t1, events_eb_registrants t2
WHERE t1.ID = t2.ID

but get the following error message:
#1060 - Duplicate column name 'id'

What is causing this error?

Please Log in or Create an account to join the conversation.

More
5 years 1 week ago #3517

H! I think, when you have same column names in two tables, you have to alias them differently in the select statement or list them just once. List the columns that you went to use and do not use * and it should work.

CREATE VIEW SwimView AS

SELECT t1.ID as MY_ID, registrant_name, event, .... (i made up these column names)
FROM events_eb_events t1, events_eb_registrants t2
WHERE t1.ID = t2.ID

Please Log in or Create an account to join the conversation.

  • Romuba
  • Romuba's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 5 days ago #3520

Thanks for that. I tried the following but nothing seemed to display:

CREATE VIEW SwimView AS

SELECT t1.event_id as event_num, user_id, first_name, last_name
FROM events_eb_registrants t1, events_eb_events t2
WHERE t1.ID = t2.ID

Last edit: 5 years 5 days ago by Romuba.

Please Log in or Create an account to join the conversation.

More
5 years 4 days ago #3521

I would need some more details to be able to help. Was the view created without any errors? Do you have matching ids in the ID columns of bot tables?

Please Log in or Create an account to join the conversation.

  • Romuba
  • Romuba's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 4 days ago #3522

I want to display results from two tables so that they are related. So that the website viewer can look for info from one table and display the related info from the other table.

This all is to do with swimmers (located in a table called events_eb_registrants) and swims (located in a table called events_eb_events)

I want to be able to display a list of all the swimmers as well as separately all the swims. That I can do without difficulty.

I also want to be able to display all the swimmers for a particular swim - either by clicking on the swim in the displayed list (preferred method) or using the swim ID.
I also want to be able to display all the swims that a particular swimmer has swum in - either by clicking on the swimmer (preferred method) or using the swimmer's ID.

Below are the table with their respective fields:

events_eb_events

id
parent_id
category_id
location_id
title
event_type
event_date
events_eb_registrants

id
event_id
user_id
group_id
first_name
last_name
organization
address
address2
city

Please Log in or Create an account to join the conversation.

  • Romuba
  • Romuba's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago #3523

Good day

Does no-one know how to resolve this problem?

Please Log in or Create an account to join the conversation.

Moderators: tomaz
Time to create page: 0.443 seconds

Contact Us

Contact us on Facebook