ORA-00918: column ambiguously defined in SELECT *

A query’s projection can only have one instance of a given name. As your WHERE clause shows, you have several tables with a column called ID. Because you are selecting * your projection will have several columns called ID. Or it would have were it not for the compiler hurling ORA-00918. The solution is quite simple: you … Read more

MySQL Cannot Add Foreign Key Constraint

To find the specific error run this: And look in the LATEST FOREIGN KEY ERROR section. The data type for the child column must match the parent column exactly. For example, since medicalhistory.MedicalHistoryID is an INT, Patient.MedicalHistory also needs to be an INT, not a SMALLINT. Also, you should run the query set foreign_key_checks=0 before running the DDL so you can create the tables in an … Read more

SqlException: DB2 SQL error: SQLCODE: -302, SQLSTATE: 22001, SQLERRMC: null

You can find the codes in the DB2 Information Center. Here’s a definition of the -302 from the z/OS Information Center: THE VALUE OF INPUT VARIABLE OR PARAMETER NUMBER position-number IS INVALID OR TOO LARGE FOR THE TARGET COLUMN OR THE TARGET VALUE On Linux/Unix/Windows DB2, you’ll look under SQL Messages to find your error message. If the code is positive, … Read more

ORA-01843 not a valid month- Comparing Dates

I have a problem when try to select data from a table filtering by date. For example: The Oracle Error is: Probably the source data of table is corrupted, in this case: How can i solve this problem? Can I change this dates for null? The results of this select, select * from nls_session_parameters; , is:

Finding duplicate values in a SQL table

Simply group on both of the columns. Note: the older ANSI standard is to have all non-aggregated columns in the GROUP BY but this has changed with the idea of “functional dependency”: In relational database theory, a functional dependency is a constraint between two sets of attributes in a relation from a database. In other words, … Read more