sql

Problem on Hql query

Hi there! I have the following hql query: from Admin a where a.genericTable is null or (a.genericTable.allowInsertion = true or a.genericTable.allowInsertion is null) The problem is that the result set is excluding all entries that are comprised on filter: a.genericTable is null Does anyone knows why? Thanks! ...

Postgresql Schema Path permanently

I need to set schema path in Postgres so that I don't every time specify schema dot table e.g. schema2.table. Set schema path (SET SCHEMA PATH a,b,c) only seems to work for one query session on mac, after I close query window (on pg-admin) the path variable sets itself back to default. How can I make it perm ? Would greatly appreciate a...

SQL SELECT using in() but excluding others.

I have a table called 'countries' linked to another table 'networks' with a many to many relationship: countries countries_networks networks +-------------+----------+ +-------------+----------+ +-------------+---------------+ | Field | Type | | Field | Type | | Field | Type ...

SELECT product from subclass: How many queries do I need?

I am building a database similar to the one described here where I have products of different type, each type with its own attributes. I report a short version for convenience product_type ============ product_type_id INT product_type_name VARCHAR product ======= product_id INT product_name VARCHAR product_type_id INT -> Foreign key t...

Performance when querying a View

I'm wondering if this is a bad practice or if in general this is the correct approach. Lets say that I've created a view that combines a few attributes from a few tables. My question, what do I need to do so I can query against this view as if it were a table without worrying about performance? All attributes in the original tables ...

PHP SQL, SELECT corresponding data from 3 tables at once?

I have 3 tables, 'u' 'd' 's' 'u' has userid divid 'd' has divid divname 's' has sname primaryuserid secondaryuserid Now what I'd like to do is display a table with rows of the following format userid, divname, sname Plus figure out a way to decipher whether userid is a primary or secondary for this sname table. I'm abl...

Is there an SQL Server equivalent to Oracle's RETURNING statement?

Is there an SQL Server equivalent to Oracle's RETURNING statement? I'm wondering if the OUTPUT clause would help. ...

SQL Server Transactions how can I commit my transaction

I have SQL Server 2005 stored procedure. Someone one is calling my stored procedure within a transaction. In my stored proc I'm logging some information (insert into a table). When the higher level transaction rolls back it removes my insert. Is there anyway I can commit my insert and prevent the higher level rollback from removing my i...

SQL Server 2008 - Database Merger and Aliasing?

Suppose I have two SQL Server 2008 databases, A and B. They initially were created with the intention to be separate, but over time have grown to both have constant references (in sprocs, views, etc) to each other. It's gotten to the point that they're effectively just two halves of the same database. So, we're considering merging them....

SQL Query Question ROW_CONCAT

Hello Guy, I have been stuck on this problem for quite awhile... I hope someone out there can give me a hand. The following table is in my database: Product_ID Color Type 1 Red Leather 1 Silver Metal 1 Blue Leather 2 Orange Metal 2 Purple Metal I am trying to get the followin...

case insensitive for sql LIKE wildcard statement

Sorry if this is a repeat. I looked around some and didn't find what I was after so here goes. SELECT * FROM trees WHERE trees.`title` LIKE '%elm%' This works fine, but not if the tree is named Elm or ELM ect... How do I make SQL case insensitive for this wild-card search? Again, apologies if this is repeated. Oh, using MySql 5 on ...

"Special" characters in ms access regarding search

Does the . (period) have any special meaning in ms access when search? For example, I have a table with 2 columns. (FETT Elements and FETT search) One of the FETT elements is called "Essa T4" and FETT search is "Essa*HT4", I would like to make the "Essa*HT4" as "Essa*.HT4" however my searching doesn't come up as expected. Does the dot...

SQL Query Help Please

Hello, I have an addition SQL question, hopefully someone here can give me a hand. I have the following mysql table: ID Type Result 1 vinyl blue, red, green 1 leather purple, orange 2 leather yellow and i am seeking the following output: ID Row One Row Two 1 vinyl blue, red, green leather purple, o...

Problem saving Text file in database using Hibernate

I'm having a problem saving large text files to MySQL database. If the text file size is around 5KB it successfully saves. If file is 148KB then I get this error from Hibernate: org.hibernate.exception.DataException: Could not execute JDBC batch update These is the SQL shows by Hibernate: Hibernate: insert into file_table (ID,FILE) ...

Storing and retrieving dynamically created pdf in sql

I have been playing around with creation of pdf documents for a project that I'm working on. I would like to store the generated pdf document in a SQL database and then later be able to retrieve this pdf as well. What are some suggestions for doing this? Can the document be stored in the database without physically creating the docume...

Invalid columns on trigger

I get the error invalid column media.user and tuid. Before running this i see that media.user does exist and i would think that the coalesce() as tuid would solve the tuid problem. Why are these columns invalid? CREATE TRIGGER media_comment_trig_0 ON media_comment AFTER INSERT AS INSERT INTO user_incoming_media_comments(recipie...

How do I combine more than one row of results based on a unique identifier

I have the following table of data: number holiday 123456 LDN 123456 NYC 123456 IRL 456789 NYC 456789 CHILE Basically each number can have up to 4 holidays; I need each number to only be displayed once, and then combine the holiday results into one field (rather than 3 in the example above for number 123456) Ideally I want the ...

One-to-many relationship related to many tables

I have a scenario where: there are two (or more) tables that represent independent items. lets say Users and Companies Both of these tables need addresses stored. Each one can have one or more address In a normal 1 to many scenario Addresses table woudl just have a UserId or a CompanyId creating a normal 1 to many relationship. In ...

how to debug a query that has valid syntax, executes, but returns no results?

So I'm writing a fairly involved query with a half dozen joins, a dependent subquery for [greatest-n-per-group] purposes, grouping, etc. It is syntactically valid, but I've clearly made at least one mistake because it returns nothing. In the past I've debugged valid queries that return nothing by removing joins, executing subqueries on...

Is it possible to modify the value of a record's primary key in Oracle when child records exist?

I have some Oracle tables that represent a parent-child relationship. They look something like this: create table Parent ( parent_id varchar2(20) not null primary key ); create table Child ( child_id number not null primary key, parent_id varchar2(20) not null, constraint fk_parent_id foreign key (parent_id) ...