sql

Rows to field level in query?

Hello, Using SQL 2005, I am trying to run a query on a Orders table in my database. Each order can have multiple 'Comments'. I want to get a single order record with all the Comments put together in one field. Here is the psuedocode for what I'm trying to do: SELECT Orders.Name, Orders.Date, (SELECT Comment += Comment FROM OrderCo...

Help getting, or displaying, random records in ColdFusion from a MySQL query?

I've got a jquery roller/scroller that displays snippets of records returned from my 'Helpful Hints' database table query. I want to keep the scroller to about 15 records but not always the first 15 records. Is it more efficient to write a query like: SELECT * FROM table ORDER BY RAND() LIMIT n Which returns a random result or do I ...

Trouble with MS Access 2007 SQL Query

Are ordinary sql queries different from MS Access 2007 queries? I have this simple query but it is not working in MS Access query (SQL View). What is wrong with this? SELECT StudentSubject.*, Subject.*,Professor.*, Student.*, Church.* FROM ( SELECT StudentSubject.*, Subject.*,Professor.* , Student.* FROM ( SELECT StudentSubject....

All Candidate keys are Superkeys whereas all Superkeys are not Candidate keys. Why?

Possible Duplicates: What's the point of a candidate key? Superkey vs. Candidate key Thanks in advance. ...

Database constraint to check against specific constraints dependent on an input value?

I'm running maintenance on a database program with no foreign key constraints, even though it really should have... There is a Logging table which has a ParentID column, and a ParentType column. The entry in the ParentType column determines which table ParentID references. What I'm looking for is for ideas on the best way to add this i...

Is it crazy to bypass database case sensitivity issues by storing original string case AND lower case?

I'm implementing a database where several tables have string data as candidate keys (eg: username) and will be correspondingly indexed. For these fields I want: Case insensitivity when someone queries the table on those keys The initially written case to be preserved somehow so that the application can present the data to the user wit...

How to dynamically choose which table (with same schema) to select from in stored procedure

I have a bit of an odd database model for a project - I'm going to have several tables with the same definition. Each table stores information for different clients and because of security restrictions, we cannot put the data together in one table. So it would look something like this... table ClientOneData ( Id (PK, int, not nul...

Building a Sql client

Hi all, I'm looking to build a sql client for a school project on iOS. My first problem here is that I'm not sure what, if any libraries I need beyond what's provided to me in the SDK to make the proper server connections. Also any security concerns you might be able to point out here would also be appreciated. ...

Recreate database schema on another system?

I have access to a remote Oracle database with a schema consisting of may tables but no data. I'd like to recreate this schema on my local database system for testing purpose. How would I go about this? Are there any utilities that can help with this? Also, if the 2 Oracle database versions are different would that be a cause of any con...

Retrieving like counts on entries from SQL.

Hey all, I've been adding a like feature to an entries database... here's the structure of the DBs: **Users** user_id user_name etc. **Entries** entry_id entry_content etc. **Likes** user_id entry_id (It's a little more complicated than that, there are groups/categories, but that should explain it fine...) Here's the SQL query I'm ...

Pervasive Sql 10 Join one table, onto another, onto another

I have a table with products. When I get information from that table, I would also like to get the ETA of that article. To do so, I am planning to get the latest purchase Order Row, that is on this article, and then get the expected delivery of this purchase. This is three different tables and I would like it to be like another column o...

Please help me debug my sql query!

I keep on getting the error "incorrect syntax near keyword 'where'." DoCmd.RunSQL "insert into userPreferences (userId, GroupId, preferenceId, properties, isDefault)" & _ "select " + Me.UserId + ", " + Me.GroupId + ", preferenceid, properties, 1 from preferences " & _ " where preferenceId not in " & _ "(selec...

What's wrong with this SQL SELECT?

Hi, I'm using SQL Server and querying it with php. I have a query that selects data based on dates entered. $tsql = "SELECT COUNT(tblBackupArchive.StatusID) AS total, tblBackupArchive.StatusID ". "FROM tblBackupArchive INNER JOIN ". "tblBackup ON tblBackupArchive.BackupID = tblBackup.BackupID ". "W...

What is wrong with the syntax of this OUTPUT statement (SQL Server 2005)?

I'm trying to use the OUTPUT statement in a stored procedure in order to return the ID of a newly inserted row. The stored procedure is: CREATE PROCEDURE PROC_RESTORE_REQUEST_TO_QUEUE @cs_uri_stem varchar(900), @cs_uri_query varchar(2500), @date datetime, @time datetime, @queue_state smallint, @process_id int, ...

Anonymous count with nhibernate criteria?

Is it possible to create a anoynmous count with nhibernate? The below query throws the exception "No column *". I could of course add a column name, but I'd prefer not to, because if I do, I'll have to lookup column names for 95 tables... NHibernate.Criterion.DetachedCriteria dcIsUniqueDomainname = NHibernate.Criterion.DetachedCriteria...

SQL - Retrieve values in a single query with multiple where clauses

I have a table with the following data: UserName | LastLogin ------------------------------- User1 | 2010-10-25 10:05:47 User2 | 2010-10-23 11:10:27 User3 | 2010-10-12 05:39:34 User4 | 2010-10-20 12:22:11 User5 | 2010-09-17 08:41:05 I want to be able to run a query to get the number of people who have logged in in the ...

Good methods or tutorials for understanding JOINs in SQL

Hi All, As we know that there are different types of JOINs in any RDBMS, for eg:- Left join, outer join, inner join, left outer join etc. Invariably we use JOINs for lots of our business logics in our projects. However very few people have complete understanding or mastery over these JOINs. Usually people with half known knowledge on JO...

i created a database in my app, but i don't find it in the DDMS

I can't find my test.db in the file manager in DDMS. Does someone know when we create a database, where it's installed ? ...

SQL duplicate data for excel dynamic table

First thanks for reading me and sorry for my bad english. I have the following code on sql server 2008 r2 SELECT FA960.*, UMCONVPZ.UMFR, UMCONVPZ.UMCONF AS Piezas, UMCONVPL.UMCONF AS PL, UMCONVCJ.UMCONF AS Cajas FROM FA960 FA960 JOIN UMCONV UMCONVPZ ON FA960.RECURV = UMCONVPZ.UMRESR JOIN UMCONV UMCON...

Simple SQL query

I have a table, with these columns: ID | Data How to find out which record has highest ID? ...