- Posts: 4
- Thank you received: 0
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
#1060 - Duplicate column name 'id'
Please Log in or Create an account to join the conversation.
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.
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
Please Log in or Create an account to join the conversation.
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.
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.
Good day
Does no-one know how to resolve this problem?
Please Log in or Create an account to join the conversation.