|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Cant display duplicate column name?
Hi,
Encounter another problem...I have 2 tables which stores employees worktime record. One of the tables stores record on the current month and the another table will store record from the previous month. When i do this query... SELECT a.emp_id, a.emp_name, a.in_time, a.out_time, a.date, b.in_time, b.out_time, b.date FROM worktime_current a, worktime_previous b WHERE a.emp_id = b.emp_id; I got this error msg ORA-00957: duplicate column name What is wrong the query?? Cant it display a column that have the same name but from different tables??? How to modify it so that the query can work? Thanks -------------------------- regards, YuLing |
|
#2
|
|||
|
|||
|
If you select columns with the same name from different tables, you need to assign a column alias for those columns:
Code:
SELECT a.emp_id,
a.emp_name,
a.in_time as a_in_time,
a.out_time as a_out_time,
a.date as a_date,
b.in_time as b_in_time,
b.out_time b_out_time,
b.date as b_date
FROM worktime_current a,
worktime_previous b
WHERE a.emp_id = b.emp_id
|
|
#3
|
|||
|
|||
|
This query suppose to work fine. If you are using this query to CREATE a new table or in INSERT clause, it will give you error message. Check your query again.
|
|
#4
|
|||
|
|||
|
Thank you...
The code work just fine as i only wants it to display the the time out, not creating a new table. But just for some additional knowledge, incase i need to CREATE a new table in the future...what should i do if the new table that i wanted to create contain two columns that have the same column name. Do i rename either one the 2 column first before i can create the new table?? Or is there an easier way to do it??Thanks Ooo and btw is there any difference between WHERE a.emp_id = b.emp_id and WHERE b.emp_id = a.emp_id ---------------------- YuLing Last edited by YuLing : April 15th, 2004 at 07:26 PM. |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Cant display duplicate column name? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|