sql

Page upload data again on page refresh in ASP.NET

For some reason when the user click on the submit button and he re-fresh the page the same data get's uploaded again to my SQL Server 2005 database. I do not what this to happen........... Why is this happening? I am making use of a SQL Data Source!! My code Try 'See if user typed the correct code. If Me.txtSecurity.T...

How can I limit an SQL query to be nondestructive?

I'm planning on building a Django log-viewing app with powerful filters. I'd like to enable the user to finely filter the results with some custom (possibly DB-specific) SELECT queries. However, I dislike giving the user write access to the database. Is there a way to make sure a query doesn't change anything in the database? Like a 'dr...

SQL Query to concatenate strings or add default value

Hello, I have to create a View that shows a field created by concatenating some other fields. The simple query that I use is this one: SELECT CODPROY, DESCPROY, USER, CODPROY + ' - ' + USER + ' - ' + DESCPROY AS Expr FROM dbo.PROY The problem is that USER may be NULL and in this case I have to insert a default text, ...

Optimizing WordPress SQL query for older posts list

On my WordPress site, when a user pages far back in the list of posts, the queries end up taking a couple seconds. I'd like to bring this down. Here's the query that's being executed: SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_s...

Entity Framework Code Generation with Indexes

Is there a way to tell .NET 4 ADO.NET Entity's SQL Generator to create indexes for a specific column? ...

Select order products in MySQL from muliple tables

I have 3 tables: orderProducts (orderId, productId, productValue), products (productId, productName) values (productId, productValue, productValuePrice). I need to select order products (product id, name, value, price) with defined orderId. How to do that with one MySQL query? ...

java.util.Date vs java.sql.Date

java.util.Date vs java.sql.Date: when to use which and why? ...

Limiting SQL Statement to top 5 amounts

How do I write a simple SELECT statment which limits the report to only the top 5 of a column value? ...

SQL join against date ranges?

Consider two tables: Transactions, with amounts in a foreign currency: Date Amount ========= ======= 1/2/2009 1500 2/4/2009 2300 3/15/2009 300 4/17/2009 2200 etc. ExchangeRates, with the value of the primary currency (let's say dollars) in the foreign currency: Date Rate ========= ======= 2/1/2009 ...

Trying to get a count of fornames which begin with eithe M or A I get right answer but is not perfect

SELECT COUNT(SUBSTR(forenames,1,1)) FROM employee WHERE (SUBSTR(forenames,1,1) like '%M%') OR (SUBSTR(forenames,1,1) like '%A%') ...

VB.NET, testing if a dataset contains rows

I'm a complete newbie to VB.NET, how can I test if a dataset has rows? I'm trying to see if my sql procedure call managed to fill up my dataset. Also, is there an easy way to print the rows to a label? ...

Index was out of range. Must be non-negative and less than the size of the collection.

Hi, I get the index out of range exception when compiling my grid view to display a set of orders. It doesn't happen when I add a new row but it does occur when I try to delete or update a row. Any help is much appreciated. The designer is: <asp:GridView ID="GridView1" runat="server" ...

Oracle SQL - How to Retrieve highest 5 values of a column

How do you write a query where only a select number of rows are returned with either the highest or lowest column value. i.e. A report with the 5 highest salaried employees? ...

Returning multiple columns from SQL procedure with .NET

I am using this vb.net code file to call a procedure to get dates (among other things). When I execute this procedure in SQL 2005 Server Management Studio, I get about 10 columns. However when I execute this code, the dataset seems to only have one index value, maybe I am misunderstanding something. When I change this ds.Tables(0).Rows...

SQL Select unique values in 1 column

Hello, I've got problem (a little problem I suppose) and I hope, you'll help me. I use Sybase Anywhere and here's my code: SELECT TOP 4 Person.Id_person, Person.Name, Person.Surname, Visit.Date, Visit.Place From Person, Visit WHERE Visit.Id_person = Person.Id_person ORDER BY Visit.DATE DESC and here's the result: 3 | Paul | McDonal...

select with subquery takes about 1min in sqlite and < 1s in SQL Server

I already looked up many posts about this problem (subqueries being very slow in sqlite). but I'm not really good with sql and i don't know what i can do. i have this query: SELECT * FROM data d WHERE d.category = 3 AND (SELECT COUNT(id) FROM data_tag WHERE data = d.id AND (tag = 2136 OR tag = 8)) >= 2 ORDER BY id ASC i have 3 tabl...

no previous outfile available in mysql console

mysqlhotcopy hospital C:\Temp I'm using the code above to backup the hospital database in MySQL. But it said that "no previous outfile available, you must give a filename." How do I properly do it? ...

Using Adodb for php/postgresql, return row ID after insert

I am using Adodb and Postgresql. When I insert a row, it increments the ID field using SERIAL. Is it possible to return the newly created ID number right after the insert? ...

Shuold I use not exists or join statement to filter out NULLs?

SELECT * FROM employees e WHERE NOT EXISTS ( SELECT name FROM eotm_dyn d WHERE d.employeeID = e.id ) And SELECT * FROM employees a LEFT JOIN eotm_dyn b on (a.joinfield=b.joinfield) WHERE b.name IS NULL Which is more efficient,some analysis? ...

Adodb: Postgresql select from two tables but return one set of results

I am new to SQL, and have two tables that hold data(I am using Adodb). They both have keys that connect them together, so I wanted to select a name from the first table if that has a parent id in the second table. I am using: $db->GetCol("SELECT x_ast.name FROM x_ast, x_ast_tree WHERE x_ast_tree.parent='$parent_id'"); This returns a...