sql

Does this feature potentially cause too many problems for non-technical users?

I am in the planning stages of writing a new program, and there's a feature I'd like to include, but I was wondering if it's too much for non-technical users to handle, or if it invites potential problems. My program is a C# app with a SQL db. I'd like to use a version of SQL that would allow the db to be accessed from multiple compute...

Select * from table with where and order by clause problem

I need to get the number of items that have a comment but I cant get this SQL statement to work for me........any advice? Select count(Name) as TotalComments from TableName where comment <> '' order by ID Error Message: Column "TableName.ID" is invalid in the ORDER BY clause because it is not contained in either an aggregate f...

Access to SQL DB in multithread server app

In my server application I want to use DB (SQL Server) but I am quite unsure of the best method. There are clients whose requests comes to threadpool and so their processing is async. Every request usually needs to read or write to DB, so I was thinking about static method which would create connection, execute the query and return the r...

SQL Query to sum fields from different tables

Hello, I'm a humble programmer that hates SQL ... :) Please help me with this query. I have 4 tables, for example: Table A: Id Total 1 100 2 200 3 500 Table B ExtId Amount 1 10 1 20 1 13 2 12 2 43 3 43 3 22 Table C ExtId Amount 1 10 1 20 1 13 2 12 2 43 3 43 3 ...

Zend framework - not entering values in database - garbage going in

Hi guys I'm in an emergency here. My code was working FINE for a while when ALL of a sudden somethings gone wrong and I havent a clue what! I store an object in my database by serializing it and then running a base64_encode on it. The result is an encoded serialised string which when I wish to retrieve I just decode and unserialise it. ...

Which Tool can generate UML by SQL?

I'm searching a tool for generating UML-Diagrams by the import of SQL-Syntax-Files. I need it for personal usage. Best if it's free or if there is a free trial license available. ...

Select database rows in range

I want to select the rows between A and B from a table. The table has at least A rows but it might have less than B rows. For example if A = 2, B = 5 and the table has 3 rows it should return rows 2 and 3. How could I get the rows in such a range? I am using Microsoft SQL Server 2008. ...

Django: Unpack argument list for use in aggregate query

I am attempting to create a semi-dynamic aggregate function that will return the sums of all fields within a list. The assumption is that running get_query_set() will return a filtered query that contains all the fields in the list and some others that may not play so well with a Sum aggregate (date fields, char fields, Foreign Keys, etc...

normalizing accented characters in MySQL queries

I'd like to be able to do queries that normalize accented characters, so that for example: é, è, and ê are all treated as 'e', in queries using '=' and 'like'. I have a row with username field set to 'rené', and I'd like to be able to match on it with both 'rene' and 'rené'. I'm attempting to do this with the 'collate' clause in MyS...

SQL: Syntax error with intersect?

This is my query: -- Sids of suppliers who supply a green part AND a red part (SELECT Suppliers.sid FROM Suppliers JOIN Catalog ON Catalog.sid = Suppliers.sid JOIN Parts ON Parts.pid = Catalog.pid WHERE Parts.color = "red") INTERSECT (SELECT Suppliers.sid FROM Suppliers JOIN Catalog ON Catalog.sid = Suppliers.sid JOIN Parts ON Parts.pid...

Terribly slow SQL query with COUNT and GROUP BY on two columns

I'm archiving this web forum, which normally gets purged about once a week. So I'm screen scraping it, and storing it into my database (PostgreSQL). I also do a little analysis on the data, with some graphs for users to enjoy, like what time of day is the forum most active, and so forth. So I have a posts table, like so: Column |...

Using multiple JOINS. SUM() producing wrong value.

Hey folks, I am getting some basic invoice information in a SQL query and figuring the Order Total and Payment Totals in the same query. Here is what I have thus far: SELECT orders.billerID, orders.invoiceDate, orders.txnID, orders.bName, orders.bStreet1, orders.bStreet2, orders.bCity, orders.bSta...

Is there a better way to write this SQL statement?

Hi, I am getting and calculating some basic order information in my SQL query. I have it working as it should but have been reading about the GROUP BY SQL Clause. I am wondering if the following SQL statement would benefit from GROUP BY and if it would be more efficient to use it? Thanks! SELECT orders.billerID, orders.invoiceDate, o...

How to get the affected rows of the Zend_DB_table?

After you do get the number of rows affected when you do $table->delete($query) does it return the number affected rows?? ...

Approach for representing command-line interface commands in code: Implementation of "database" where a query and result is obtained from proprietary CLI commands.

Problem Domain: I am working on a new revision of a Java application that connects via SSH to a proprietary, Linux-based platform's Command Line Interface (CLI). Everything on the platform that I would want to do or know is only available via CLI commands and stdout. One of the commands available retrieves information from an intern...

Keeping SQL Dry

Here is a MySQL query I'm running: -- get the sid of every supplier who does not supply both a red and green part SELECT Suppliers.sid, Parts.color FROM Suppliers JOIN Catalog ON Catalog.sid = Suppliers.sid JOIN Parts ON Parts.pid = Catalog.pid WHERE Suppliers.sid NOT IN ( SELECT Suppliers.sid FROM Suppliers JOIN Catalog ON ...

SQL: Help with a nested queries

Here is my schema: Suppliers(sid: integer, sname: string, address string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real) bold indicates primary key. I want to write a query to find all suppliers who supply every part. Here are two queries I have already: -- get all parts for a giv...

How would I send all my data from one table to another,SQL?

I want to transfer the data from one table in sql to another is there a way to do this ? ...

How I can obtain the collation of a specific table in a database?

How I can obtain the collation of a specific table in a database? Is it possible that a table have different collation in db? ...

Complex SELECT statement; one-to-many all details in one row

There are two tables: Products ID (Primary Key), ProductName PlannedByMonths ProductID (Primary Key) (Link to the Products table many-to-one), MonthNumber (Primary Key), QtytoProduce, How to write SELECT statement to retrieve results in the following format? ProductName, QtytoProduceMonth1, QtytoProduceMonth2, QtytoProduceMonth3,...