sql

MySQL Syntax Error

When executing: BEGIN DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN ROLLBACK; SELECT 1; END; DECLARE EXIT HANDLER FOR SQLWARNING BEGIN ROLLBACK; SELECT 1; END; -- delete all users in the main profile table that are in the MaineU18 by email address DELETE FROM ap_form_1 WHERE element_5 ...

What do you put in a subquery's Select part when it's preceded by Exists?

What do you put in a subquery's Select part when it's preceded by Exists? Select * From some_table Where Exists (Select 1 From some_other_table Where some_condition ) I usually use 1, I used to put * but realized it could add some useless overhead. What do you put? is there a more efficient wa...

Monitoring SQL JOB Performance Issues

I am working on a SQL Job which involves processing around 75000 records. Now, the job works fine for 10000/20000 records with speed of around 500/min. After around 20000 records, execution just dies. It loads around 3000 records every 30 mins and stays at similar speed. I asked a similar question yesterday and got few good suggestions...

SQL Server: Inline Table-Value UDF vs. Inline View

I'm working with a medical-record system that stores data in a construct that resembles a spreadsheet--date/time in column headers, measurements (e.g. physician name, Rh, blood type) in first column of each row, and a value in the intersecting cell. Reports that are based on this construct often require 10 or more of these measures to b...

Does mysql_num_rows recount all the rows, or does it just grab a total after a select statement?

I wasn't sure if it recounted the rows, or if after it retrieved the whole result set, it only grabbed the total post query? ...

Mysql Date SELECT

I'm trying to select all dates that haven't pass the current date. So for instance, I want to display every date after 2009-10-06 and NOT dates prior 2009-10-06. ...

Create view with results in a single column in mysql

I would like to create a view that has a single column. If my two tables looked like the following: Table 1: ID | Name 1 | Joe Table 2: ID | Address 1 | 123 BlueBerry St. The view would look like: View: newcolumn | Joe 123 Blueberry St. The reason I do this is because I have an autocomplete text box that searchs a single colum...

SQL IsNumeric(), shouldn't it return a bit?

I'm just curious to know why SQL IsNumeric() returns int instead of bit? Seems like it should return a bit. ...

How to mimick Oracle Materialized Views on MS SQL Server?

Application connected to MS SQL Server will create views where a single row result is an analysis including aggregations of 1-10k records. The applicable criteria across the resulting view will have dozens to tens of thousands of results. The view+criteria will then be ordered by some column (user specified) in the view which are most li...

Oracle number in parentheses instead of the field name

There is a functionality in Oracle which permits to use a number in parentheses instead of naming a field to order a result. Example : this query order the result by the "id" column : select name, id from table order by (2) What is the name of this functionality and where can I can read documentation on it ? ...

SQL Server 2008 data types

What are the different SQL Server 2008 data types? I am specifically trying to find the equivalent of a long int. ...

How do SQL Server View Indexes work under the hood?

How do SQL Server View Indexes work under the hood? I've read this TechNet article but it doesn't explain how a view index actually works. Can anyone explain this to me? Note: I'm not sure if this should have gone on SF. If it should, just move it over there. ...

linked-server sql - access Problem

Hi, I have a SQL server 2000 and an Access database mdb connected by Linked server on the other hand I have a program in c # that updates data in a SQL table (Users) based data base access. When running my program returns the following error message: OLE DB provider 'Microsoft.Jet.OLEDB.4.0' reported an error. Authentication failed. [...

sql query not working in drupal when fetching more than 100 rows

I was trying to execute this mysql query it is not giving me any results if i set the query_limit to more than 100, can somebody point me what i can do to get this working for fetching more data. $query_limit = 190; $query1 = "SELECT N.nid ,N.tid FROM term_node N JOIN term_data S ON S.tid = N.tid AND S.vid =1"; $query_result = db_quer...

SQL command for conditional join for PROGRESS database

Please bear with me new to SQL- I am trying to write an SQL command with a join in a PROGRESS db. I would like to then select only the first matching record from the join. I thought to use LIMIT but PROGRESS does not support that. MIN or TOP would also work I think but having trouble with the syntax. Something like this?- SELECT table1....

SQL Aggregation for a smaller result set

I have a database for which I need to aggregate records into another smaller set. This result set should contain the difference between maximum and minumum of specific columns of the original records where they add up to certain SUM, a closed interval constant C. The constant C determines how the original records are aggregated and no ...

SQL command for PROGRESS database

Please bear with me new to SQL- I am trying to write an SQL command with a join in a PROGRESS db. I would like to then select only the first matching record from the join. I thought to use LIMIT but PROGRESS does not support that. MIN or TOP would also work I think but having trouble with the syntax. Here is current syntax: SELECT esth...

Get records before and after current selection in Django query

It sounds like an odd one but it's a really simple idea. I'm trying to make a simple Flickr for a website I'm building. This specific problem comes when I want to show a single photo (from my Photo model) on the page but I also want to show the image before it in the stream and the image after it. If I were only sorting these streams by...

How Should This SQL with Left Joins be Written in Access 2007?

I have a sql statement with multiple left joins that I cannot get to work in Access 2007, the message stating, JOIN expression not supported SELECT Foo.A, Bar.B, Baz.C, Bat.D FROM Foo LEFT JOIN Bar ON Foo.BarId = Bar.BarId LEFT JOIN Baz ON Foo.BazId = Baz.BazId LEFT JOIN Bat ON Foo.BatId = Bat.BatId WHERE Foo.Cr...

Return one row for each ID based on date column (SQL)

The DDL creates the schema and data. I am looking for a where statement where it returns only one row for each ID and that row would be the last inserted row based on the inserteddate column. So the result would be John, 5 and Debbie, 5 select Table1.Name, Table2.Rating From table1 join table2 on table1.ID = table2.ID where inserteddat...