sql

Incrementing a click counter in MySQL

How do you increment a value in a mysql table by one each time for example if a link is pressed ? Do you get the data from the database and then add 1 to it and then send it back ? I assume that would use a lot of bandwith. Any examples and help would be appreciated, Thank you! Added: I would also like to keep track of who has pre...

Do all RDBMS have a Data Dictionary comparable to the one Oracle has?

Is it possible to retrieve information like: the tables the indexes with the columns they index the columns in each table along with their types constraints like unique keys, foreign keys, not null .. using sql from all (major) RDBMSs? I know it is possible for oracle and assume it is possible for most others. Are there any importa...

sqlite SQL query for unprocessed rows

Hi, I'm not quite even sure where / what to search for - so apologies if this is a trivial thing that has been asked before! I have two tables in sqlite: table_A = [id, value1, value2] table_A$foo = [id, foo(value1), foo(value2)] table_A$bar = [id, bar(value1), bar(value2)] Where foo() / bar() are arbitrary functions not really rele...

Find the top value for each parent

I'm sure this is a common request but I wouldn't know how to ask for it formally. I encountered this a long time ago when I was in the Army. A soldier has multiple physical fitness tests but the primary test that counts in the most recent. The soldier also has multiple marksmanship qualifications but only the most recent qualification...

Trying to modify a monthly report to a weekly. Aspen Sql

I am very new to SQL programming. I am trying to modify a monthly runtime report so that I can get the information on a weekly time interval. My code just outputs 0's when the starttime and endtime are in the same month. I can't figure out why. Function TagCount ( Tag1Name char(24), Tag1Cond integer, Tag2Name char(24), Tag2Cond integer...

Prepared statements in Entity Framework

How can I run a prepared statement against a database and have the returned rows automatically attach to the entity framework data context? Essentially, how can I achieve the same functionality of ObjectContext.Execute except using a prepared SQL command. ...

call stored procedure for each record

Hello! I have sql stored procedure which pass and return some values: CREATE PROCEDURE [dbo].[GetMoney] @userId int, @month DateTime AS BEGIN .... Select @something END I want to call GetMoney procedure for each user in users table and use results in sql query. How can i do it? ...

Retrieve order numbers without certain items

I have a table with some ice cream order data like so: id order_number item_name 1 1 cake cone 2 1 sprinkles 3 2 sugar cone 4 3 semi-sweet morsels 5 3 sprinkles (This is simpler than the real table but the relevant columns are present.) Essentially what I want to...

Fast single table database.

I have an analytics database where I make complex queries. Each of these queries generates thousands of rows. I want to store these results in some kind of on disk cache so I can get the results later on. I can't insert the results back into the database where the results came from as that database is read only. The requirements of this ...

SQL Datetime difference in days

I am trying to find how many days are between two dates. I have been attempting to use this: SET Days_Outstanding = DATEDIFF(day, CONVERT(datetime, LS_CHG_DTE_EQP, 1), CONVERT(datetime, Report_Date, 1)) However, this is not returning the number in days. It's returning a datetime in years that have nothing to do with my data set. ...

Using phpmyadmin to manage duplicates

Hi! I'm looking for a tool that allows me to easily manage duplicate entries in the MySQL database. In a sense, I don't want to make my columns 'UNIQUE', but I want to review the records that happen to have exactly the same value in a column. It would be nice if I could craft such an SQL query that shows only such records using the us...

Oracle SQL Error: How to Debug this issue

Using: select name, id from "TEST" where id :2 AND name :1 order by id desc I am getting ORA: 00904 "TEST"."NAME": invalid identifier error but the wierd part is that I have checked my test table and it does not have NAME field but it has name field, I have also checked all the references which is made from that tabl...

SQL select statement dynamical multiple conditon

I have 3 tables, say images(id), news(id), types(id, category, obj_id, type) For example, categories of news A are black, red. data struct is like { types(xxxx1,red,news_A,news) types(xxxx2,black,news_A,news) } now I need find out all images with type red and black. In this case, I need images_B { types(oooo1,red,images_B,i...

SQL to Insert data into multiple tables from one POST in WebMatrix Razor Syntax

I've got two form fields from which the user submits a 'category' and an 'item'. The following code inserts the category fine (I modified it from the WebMatrix intro PDF) but I've no idea how to then insert the 'item' into the Items table. I'll also need to add the Id of the new category to the new item row. This is the code that's wor...

can i delete rows from 2 tables in one single SQL statement?

Hi there. I have 2 tables one called "REVIEW" and the other "REVIEW_DESCRIPTION" if i do a join to get all the data from both: SELECT * FROM reviews INNER JOIN reviews_description ON reviews.reviews_id=reviews_description.reviews_id WHERE reviews.customers_id = 54183 based on this i would like to delete rows in both tables that mat...

SQL Server Select Question

I have a query, say Select foo from bar Foo is a string field, and will always start with "http://". I want to replace "http://" with "xml://" during the select, so all foo values come back as xml://..., instead of http://... Is there a way to substitute on the fly, during the query? ...

How to store the index separately from the data on Azure?

I've read that a lot of websites store the index separably from the data. Specifically on Azure, the index will be stored in Azure SQL and the data stored in Azure Table Storage. This supposedly increases the performance and allows you to store a lot more data and query it efficiently. I'm not sure how to architect a system to do t...

Having trouble with a SQL report for Dynamics CRM

I am trying to create a statement like report for invoices, I have it so far that it displays the invoice and the amount due and also the payment if it has been paid, I have all this in a table with the invoice on 1 line and the payments on another with them grouped. What i really what to achieve is to have them ordered by date and for i...

Image rating aplication problems in C#

Hello!! I have a problem with the picture rating application that I am working on. I don’t regularly program with C#, so if anyone could help, that would be the best thing that has happened so far to me!! I am programming in visual studio 2008, the base for the application is made in Microsoft Access. So what I am trying to do: I hav...

SQL max for previous rows

I have Ticker, Dt, [Open], Volume for the input table Dt is yyyy-mm-dd I want to return every row where ticker = 'IBM' and also returns the Ticker, Dt, [Open], Volume fields and then include a max column for only say for the previous x days. Let's say 3 days for the sake of not posting too much data. But I don't know how to get the ...