Notices
The Basement Non-Honda/Acura discussion. Content should be tasteful and "primetime" safe.

People that know SQL - Help please!

Thread Tools
 
Old Oct 2, 2007 | 07:09 AM
  #1  
Pete's Avatar
Pete
Thread Starter
Civilian
 
Joined: Jun 2003
Posts: 8,407
Likes: 1
From: Miami Beach. FL
Default People that know SQL - Help please!

I am writing a query in this SQL program for my class and I keep getting this error:

ORA-00918: column ambiguously defined

Although I know you can't really test it, here is the code:


Code:
-- program: U403.sql
-- author: Peter Nagy ciss-250 Fall 07
-- date: 10-2-2007
-- purpose: Prompt user for pilot license type and return pilot information.

TTITLE 'RobAir - Pilot Info Based on License Type Entry'
ACCEPT my_pilot_license_type CHAR PROMPT 'Enter Pilot License Type (COM or ATP): '
COLUMN pil_pt135_date -
HEADING 'Proficiency Test Date'
COLUMN emp_hire_date -
HEADING 'Hire Date'
SELECT (employee.emp_fname ||' '|| employee.emp_lname) Pilot,
              pilot.pil_pt135_date,
              employee.emp_hire_date
FROM hartmar.employee, hartmar.pilot
JOIN hartmar.pilot ON employee.emp_num = pilot.emp_num
WHERE pilot.pil_license = '&my_pilot_license_type'
ORDER BY Pilot
;
Apparently, the problem is in my select statement. But the error is supposed to mean that there are two columns with the same name in two different tables that I am trying to access. The resolution says to prefix the column names with their respective table names which I did and I still can't get it to work. Any ideas?
Reply
Old Oct 2, 2007 | 08:13 AM
  #2  
Grifter's Avatar
Grifter
Senior Member
 
Joined: Dec 2000
Posts: 44,835
Likes: 0
From: the southwest
Default

try hartmar.dbo.table?
Reply
Old Oct 2, 2007 | 09:19 AM
  #3  
Pete's Avatar
Pete
Thread Starter
Civilian
 
Joined: Jun 2003
Posts: 8,407
Likes: 1
From: Miami Beach. FL
Default

Still didn't work
Reply
Old Oct 2, 2007 | 09:30 AM
  #4  
dieneverknowing's Avatar
dieneverknowing
Senior Member
 
Joined: Nov 2006
Posts: 165
Likes: 0
From: jax fl
Default

Try this. Not sure if it'll work but it's worth a shot.

Code:
SELECT (e.emp_fname ||' '|| e.emp_lname) Pilot, p.pil_pt135_date, e.emp_hire_date
FROM hartmar.employee e, hartmar.pilot p
JOIN hartmar.pilot ON e.emp_num = p.emp_num
WHERE p.pil_license = '&my_pilot_license_type'
ORDER BY Pilot;
Reply
Old Oct 2, 2007 | 09:33 AM
  #5  
Pete's Avatar
Pete
Thread Starter
Civilian
 
Joined: Jun 2003
Posts: 8,407
Likes: 1
From: Miami Beach. FL
Default

Originally Posted by dieneverknowing
Try this. Not sure if it'll work but it's worth a shot.
ORA-00904: "E"."EMP_NUM": invalid identifier
Reply
Old Oct 2, 2007 | 09:34 AM
  #6  
Grifter's Avatar
Grifter
Senior Member
 
Joined: Dec 2000
Posts: 44,835
Likes: 0
From: the southwest
Default

SELECT (employee.emp_fname ||' '|| employee.emp_lname) Pilot,
is pilot an alias?
Reply
Old Oct 2, 2007 | 09:37 AM
  #7  
dieneverknowing's Avatar
dieneverknowing
Senior Member
 
Joined: Nov 2006
Posts: 165
Likes: 0
From: jax fl
Default

Originally Posted by Pete
ORA-00904: "E"."EMP_NUM": invalid identifier
Is 'emp_num' the correct column name under the employee table?
Reply
Old Oct 2, 2007 | 09:43 AM
  #8  
Pete's Avatar
Pete
Thread Starter
Civilian
 
Joined: Jun 2003
Posts: 8,407
Likes: 1
From: Miami Beach. FL
Default

Originally Posted by Grifter
SELECT (employee.emp_fname ||' '|| employee.emp_lname) Pilot,
is pilot an alias?
Yes.

Originally Posted by dieneverknowing
Is 'emp_num' the correct column name under the employee table?
Yes.

Don't know if you guys can see it, but here is the database structure:

Attached Images
File Type: gif
ERD.gif (65.9 KB, 62 views)

Last edited by Pete; Oct 2, 2007 at 09:47 AM.
Reply
Old Oct 2, 2007 | 09:47 AM
  #9  
Grifter's Avatar
Grifter
Senior Member
 
Joined: Dec 2000
Posts: 44,835
Likes: 0
From: the southwest
Default

https :doh:
Reply
Old Oct 2, 2007 | 09:48 AM
  #10  
Pete's Avatar
Pete
Thread Starter
Civilian
 
Joined: Jun 2003
Posts: 8,407
Likes: 1
From: Miami Beach. FL
Default

Originally Posted by Grifter
https :doh:
fixed
Reply



All times are GMT -8. The time now is 03:31 PM.