sql

Trying to speed up a SQLITE UNION QUERY

I have the below SQLITE code SELECT x.t, CASE WHEN S.Status='A' AND M.Nomorebets=0 THEN S.PriceText ELSE '-' END AS Show_Price FROM sb_Market M LEFT OUTER JOIN (select 2010 t union select 2020 t union select 2030 t union select 2040 t union select 2050 t union select 2060 t union select 2070 t ) as x LEFT OUTER JOIN sb_Selection S ON S....

DB2 cascade delete command?

Is there a special syntax to execute a cascade delete on DB2 or is it only possible to create "cascadable" tables by defining them with the "ON DELETE CASCADE" option? What I am trying to achieve is delete other table rows based on a same foreign key when I delete that key, but this is done on an already existing and data-filled databas...

Retrieving a row, with data from key-value pair table in MySQL

I have two tables, one called customer and one called customer_attributes. The idea is that the customer table holds core customer data, and the application can be customised to support additional attributes depending on how it is used. customer_attributes has the following 3 columns: customerID key1 value1 Can I retrieve the full r...

Help Constructing an Oracle SQL with Condition

Hi. I need some help in creating an Oracle SQL which I will execute in .NET. I need to update a column in a table but the value to update the same would be dependent on two different values. To give an example: Dim sqlcmd as String Dim collCmd as Collection For x = 1 to intCount sqlcmd = "Update tableA Set col1 = :val1, col2 = :...

Using the distinct function in SQL

I have a SQL query I am running. What I was wanting to know is that is there a way of selecting the rows in a table where the value in on one of those columns is distinct? When I use the distinct function, It returns all of the distinct rows so... select distinct teacher from class etc. This works fine, but I am selecting multiple col...

select latest 2 records of each product id in single table

this is my table structure, create table ArticleTbl ( ArticleID bigint identity(1,1), ProductID int , ArticleName varchar(100), PubDate datetime, AuthorName varchar(50), AuthorImage bit, HtmlValues nvarchar(max) ) here productid are 1=creditcard,2=prepaidcard,3 saving account,......... each productid is having multiple rows of reco...

Modeling an assembly line in SQL Server

I want to model an assembly line in SQL Server. This object would progress through a linear set of steps. Each step would have a linear set of statuses: Waiting, In Process and Completed. Which is the best approach for capturing data about a change in step and/or state? Insert one record for the object and update a step field and a st...

whats the fastest way to insert streaming data into a table, DB is MS SQL server 2008

Hi! I've to write a c++ application that receives a huge data stream( many thousands of messages per second) and insert it into a MS sql server2008 db (into one or more tables) as fast as possible. I'm new to windows, and amongst so many ways described in msdn, I'm not able to judge the best way to do this, for example: 1. should I use ...

Zend Select with self join overwriting fields

Posts and comments are stored in the same table. So to get each post and its comments we do this: $posts = $this->select()->setIntegrityCheck(false) ->from(array('post' => 'Posts'), array('*')) ->where('post.idGroup = ' . $idGroup) ->where('post.idTopic IS NULL') ->order('post.date DESC') ->limit($resultsP...

vba sql problem

Below query is showing error Please help : DoCmd.RunSQL ("insert into tbltesting (IsDiff)values ('Yes') where empid= '" & Me.txtEmpId.Value & "' and testid= '" & Me.txtAutoNumber.Value & "'") ...

Clean OO-structure vs. SQL performance

When programming in PHP I always try to create meaningful 'models' (classes) that correspond to tables in the database. I often encounter the following problem: Assuming that I've created a database with two tables: authors and blogs, which both have a corresponding model in my application. Let's say I want to print all the blogs along...

Simple access to a sql .db3 file using .NET - how?

Lost in the talk of ADO, LinQ and System.Data.SQLite. What's the easiest way of accessing (for read & write) a SQL (.db3) database file using .NET. Are we really talking about writing SQL queries or is there something higher level that is provided by MS or similar. ...

SQL Filter Query

I have a table with a number of fields in it. I am trying to create search filter in asp.net so the user can search by one or a combination of fields. So basically I want to create a single stored procedure that takes in 4 params and it will append the param to the WHERE clause if its not null... TableExample has 4 columns, Col1 Col2 Co...

Oracle Query Optimization

I have the following tables Master Table id ---- 1x 2x .... Assignment Table id | type_id | assign_id ----------------------------- 1x | 2 | 554 1x | 3 | 664 2x | 2 | 919 2x | 4 | 514 Type table type_id | create_date ---------------------- 1 | 01/01/2009 2 | 01/...

Dataset times out while query runs immediately

I am running a query directly, it is trivial in nature: SELECT * FROM [dbo].[vwUnloadedJobDetailsWithData] WHERE JobId = 36963 When I run this from Management studio the query doesn't even take a second. When I run it from within the table adapter it times out. I have fixed this multiple times, but the fix is ludicrous. If I delete...

SQL Error Locating Server/Instance Specified

Having a problem moving a site from Win2003 IIS6 w/ SQL2005 Express to a Win2008 IIS7 w/Fill SQL 2005? I keep getting this error Desc : SQL Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. Can anyone point me in the right direction ...

How do I programmatically add an apostrophe before and after a string and add a comma inbetween?

I get lists in Outlook, Word or Excel of hundreds of strings like so: 7864750A 7888801BZ 5189748C 48982572E 6936001F 7096235FG 3218833H etc. Currently I run a stored procedure on each of these, in one-by-one fashion. How could I programmatically add an apostrophe before and after a string and add a comma inbetween, like so: ('7864750A...

Optimizing ORDER BY Query on large table MySQL

I have a browse category query that im trying to optimize. Im ending up with Using temporary; Using filesort in the explain and the query is slow on a category with say 60,000 rows. If i remove the Order By clauses the query runs very fast .05 seconds to do 60,000 rows. With the Order By clauses its very slow around 5 seconds. Parts cont...

VBA update query

Below query is resulting zero rows updated but i am sure that there is a record to update DoCmd.RunSQL (" Update tbltesting set IsDiff ='Yes' " & _ "where empid= " & Me.txtEmpId.Value & _ " and testid= " & Me.txtAutoNumber.Value & ";") Please help!! ...

Oracle left outer join query

select a,last_note_user,c,d,iso_src from X,Y,Z left outer join W ON (W.last_note_user=Z.userid AND W.user_ten=Y.iso_src) when I am executing the above query it is giving me the error "Y.iso_src" is a invalid identifier.However,Y.iso_src is a valid identifier and it exist in the system table. Is something wrong with the above left outer...