I am using Hibernate JPA and Spring with a Mysql database and I want to insert using a SQL statement like this: But after running it I get the following error: Could someone help me on this please? PS. I am aware of using hibernate in non-native way, but I need to use native way. I am also of insert
Tag: sql
SQL query: select five most commented posts from different blogs
I have a following tables Blogs(id) and Posts(id, blog_id, comment_count) I need to select five most commented posts from different blogs. It’s quite easy to do with a function, but is it possible to …
ORA-00054 Resource busy when dropping table
Can somebody explain this error? ORA-00054: Resource busy and aquire with NOWAIT specified This error came in a DROP TABLE. Because of it, procedures and packages are not getting compiled.
SQL Views “WITH CASCADE CHECK OPTION” Behaivor?
I can’t find any reference, or documentation on this. Does the condition clause read x = 1 AND y = 1 in case of UPDATE/INSERT on view2? Answer OK, so maybe have a look at WITH CASCADED CHECK OPTION and it’s example and Defining Views It would seem that the WITH CASCADE option does enforce all view…
How do I select dates between two given dates in an Oracle query?
How do I select dates between two given dates in an Oracle query? Answer from http://forums.devshed.com/oracle-development-96/select-all-dates-between-two-dates-92997.html
MySQL query finding values in a comma separated string
I have a field COLORS (varchar(50)) in a my table SHIRTS that contains a comma delimited string such as 1,2,5,12,15,. Each number representing the available colors. When running the query select * from shirts where colors like ‘%1%’ to get all the red shirts (color=1), I also get the shirts whose …
Optimizing SELECT COUNT to EXISTS
I have a query to find certain customers from a table. There is an index on customerid, so the DB scans all rows with customerid = 22. Since the result is processed by checking whether the count returns zero or more than zero, how can I optimize the query? I.e. such that at the first customer row with amount …
DISTINCT for only one column
Let’s say I have the following query. How can I modify it so that it returns no duplicate Emails? In other words, when several rows contain the same email, I want the results to include only one of those rows (preferably the last one). Duplicates in other columns should be allowed. Clauses like DISTINCT…
Multiple strings in one SQL field
I am trying to revamp an order system for an e-commerce web site. The header table for the orders is tbl_orders, that’s working fine but there is another table underneath that (so to speak) called tbl_orderitems In this table tbl_orderitems I store an Id that refers to the items image but sometimes ther…
SQL and escaped XML data
I have a table with a mix of escaped and non-escaped XML. Of course, the data I need is escaped. For example, I have: <…