I am getting the following error when inserting data into my oracle database. In database date is as: dd-MMM-yy (06-MAR-12) I am converting 06-03-2012 to dd-MMM-yy by the following method: So i got 06-Mar-12 which is same as the above database date format still i am getting the error. I am inserting as: in in…
Tag: sql
Return all duplicate rows
I’ve written this code to find duplicates and it works fine: The problem is, it’s returning just one of the duplicate rows. Is it possible to return all the duplicate rows? I’m guessing it may have something to do with the ‘GROUP BY’ but I’m not sure how to change it. I don…
Difference between primary key and unique key
I’m using a MySQL database. In which situations should I create a unique key or a primary key? Answer Primary Key: There can only be one primary key constraint in a table In some DBMS it cannot be NULL – e.g. MySQL adds NOT NULL Primary Key is a unique key identifier of the record Unique Key: Can …
Can I change the default schema name in entity framework 4.3 code-first?
Currently I am deploying my application to a shared hosting environment and code-first with migrations has been working great except for one minor hiccup. Everytime I want to push the site I have to use the “Update-Database -script” option because I have to prepend every table name with [dbo] beca…
Deleting duplicates rows from oracle
I am using oracle database.I want to use duplicate rows from a table except one,which means that I want to delete all rows but atleast one row should be there. I have a table Now i want to delete duplicate rows but at least one row should be there. i had used this to find number of employees that are
Prevent SQL injection attacks in a Java program
I have to add a statement to my java program to update a database table: String insert = “INSERT INTO customer(name,address,email) VALUES(‘” + name + “‘,’” + addre + “‘,’” + email + “‘);”; I …
Difference between SQL JOIN and querying from two tables
What is the difference between the query and this one Answer There is a small difference in syntax, but both queries are doing a join on the P_Id fields of the respective tables. In your second example, this is an implicit join, which you are constraining in your WHERE clause to the P_Id fields of both tables…
Getting max value from rows and joining to another table
Sorry if this is being stupid, I am really a newbie trying to nail this. Table A: ID Rank Name 1 100 Name1 1 45 Name2 2 60 Name3 2 42 Name4 2 88 Name5 Table B: ID FileName 1 fn1 …
Search between two SQL tables?
I have two tables: student Columns first_name last_name teacher_accounts Columns fname lname I have an input form that takes the data entered into an input field, and passes it through the …
How to populate a table’s foreign keys from other tables
I’ve got the following tables, of which translation is empty and I’m trying to fill: The source data to fill translation is a temporary table that I’ve populated from an external CSV file: What I’d like to do is to fill translation with the values from tmp_table. The translated field c…