sql

Page redirecting before SQL has excuted - ASP.NET MVC

I have a slightly modified AccountController that should write a row into a table upon login. However, the page redirects before the DB action has completed and so nothing is inserted. I've temporarily solved this by sticking in a Thread.Sleep, but I'm looking for an alternative that makes it appear seamless. If Not String.IsNullO...

Does SQL's DELETE statement truly delete data?

Story: today one of our customers asked us if all the data he deleted in the program was not recoverable. Aside scheduled backups, we shrink the log file once a day, and we use the DELETE command to remove records inside our tables where needed. Though, just for the sake of it, I opened the .mdf file with an editor (used PSPad), and se...

SQL Inner join on select statements

Hello, I am trying to make an inner join on a select statement like this: select * from (select* from bars where rownum <= 10 )as tab1 inner join (select * from bars where rownum <= 10 )as tab2 on tab1.close=tab2.close and I get the following error: ORA-00933 SQL command not properly ended Any help would be appreciated, thank you! ...

Why does mysql_affected_rows return 0 even if one record should be updated

mysql_query("update users set balance=balance+'$pwbalance'-'$totalprice' where memberid='$memberid' and (balance+'$pwbalance'-'$totalprice')>=0")or die(mysql_error()); $count=mysql_affected_rows(); When I echo $pwbalance, it is 40.00; when I echo $totalprice, it is 40; So there should be one record to be updated. However, when I echo $...

SQL Inner join on select statements

Hello, I am trying to make an inner join on a select statement like this: select * from (select* from bars where rownum <= 10 )as tab1 inner join (select * from bars where rownum <= 10 )as tab2 on tab1.close=tab2.close and I get the following error: ORA-00933 SQL command not properly ended Any help would be appreciated, thank you! ...

Get TOP rows out of child table WITH inner join

I want to inner join with a child table based on ID and get the top Row of the child table, I am not joining to take any data out of the child table, its just to validate that child table record exists for parent table. If I dont include TOP row there is chances of getting multiple rows of parent in the result set. -- Chances of multipl...

How to have a simple sticky position article list in a MySQL database that can be retrieved with only one query?

I have a paginated list of articles that needs to be sorted by rank but when an article has position <> 0 then it must be inserted in that specific position. I thought that I can at least have the articles with the correct position extracted for the current page and then sort them in PHP to show then in the proper position. I want to do ...

Query result organization

I am trying to figure out the most efficient way to format this query. I have three tables - Transaction, Purchase and Item. The desired result is to select sales data (quantity/sales total) for each item for a specific client. the tables are formatted as follows: (=primary key)* Transaction: Transaction_ID*, Timestamp Purchase: P...

Nested SELECT clause in SQL Compact 3.5

In this post "select with nested select" I read that SQL Compact 3.5 (SP1) support nested SELECT clause. But my request not work: t1 - table 1 t2 - table 2 c1, c2 = columns select t1.c1, t1.c2, (select count(t2.c1) from t2 where t2.id = t1.id) as count_t from t1 Does SQL Compact 3.5 SP1 support nested SELECT clause in this c...

SQL BETWEEN 2 date values HELP

SELECT * FROM myDateTable WHERE date_Start OR date_end BETWEEN DateValue('" & CoverMonth_start & "') AND DateValue('" & CoverMonth_end & "')" TheCoverMonth start and end dates are looping from January to December. This query is suppost to select only the records WHERE date_Start OR date_end BETWEEN DateValue... B...

compare date/time via VBA with date/time in Access DB

Hi, How to compare a date/time via VBA with a date/time in an Access DB? The query I use adoRS.Open "SELECT * FROM currentpositions WHERE ((currentpositions. [dateLT])=" & "#" & date_from_message & "#" & ")", adoConn, adOpenStatic, adLockOptimistic I only achieve to compare a date. Anybody an idea? Regards Camastanta ...

DDL statements against deleted inserted in DML trigger

I am trying to find impact of doing DDL statement against deleted and inserted logical tables inside table trigger. I have: CREATE TRIGGER [Trigger52] ON [dbo].[Table1] FOR DELETE, INSERT, UPDATE AS BEGIN create table inserted (c1 int) select * from inserted END When it is triggered, I expected to g...

Sql = how to calculate the return vector with a time series of prices?

Hello, I have a table which has columns of price and date, ordered by the ascending dates. I need to calculate from this a return vector where return = price ( i) / price ( i- 1). The time is not time based, which means that one record can be at 9h34, the next at 9h35, then 9h40 etc... I have found the following topic: SQL Syntax for ca...

ORACLE - tables

Hi, After entering code to create a new table in SQL ORACLE, would the changes be saved if I was to log out of the SQL Session? ...

How to append distinct records from one table to another

How do I append only distinct records from a master table to another table, when the master may have duplicates. Example - I only want the distinct records in the smaller table but I need to insert/append records to what I already have in the smaller table. ...

Which type of join can I use to reproduce these results.

I have the following view which contains this data ActivityRecId RegionRecId IsExcluded 1 null 1 2 null 1 3 1 1 3 2 1 4 1 1 5 null 0 What I would like to do is join the region table to the view above to get the fo...

How can I connect to an external database from a sql statement or a stored procedure?

When running a SQL statement or a stored procedure on a database, can you connect to an external database and pull data from there? something like: SELECT a.UserID, b.DataIWantToGet FROM mydb.Users as a, externaldb.Data as b ...

Little help with making this basic search function work (Zend Lucene)

I have two php files so far, test.php: <?php include("../config_conn_fordon_db.php"); include("../config_open_db.php"); // Fix Special Characters mysql_query("SET NAMES 'utf8'") or die(mysql_error()); mysql_query("SET CHARACTER SET 'utf8'") or die(mysql_error()); $root = realpath($_SERVER["DOCUMENT_...

SQL: Sequentially doing UPDATE .WRITE on VarBinary column

Hi all, I'm trying to create a little test application which reads chunks of a FileStream and appends it to a VarBinary(max) column on an SQL Server 2005 Express. Everything works - the column gets filled as it's supposed to, but my machine still seems to buffer everything into memory and I just can't see why. I'm using the following ...

Need help with SQL aggregation query

What is the most straightforward approach to producing a data set that can be used in a SQL Server Reporting Services report to display the following: SalesPerson # Sales # Gross Profit John Doe 100 $140,000 $25,000 Everyone Else (Avg.) 1200 $2,000,000 $250,000 Jane Smith ...