database-queries

What is wrong with my index on this MySQL query?

select xml_record_product.product_id, IfNull(xml_record_product.product_short_description,xml_record_product.product_description) AS BookDescription, xml_record_product.product_image, xml_record_product.product_publisher_name AS Publisher, xml_record_prod...

SQL Question: select cities distance without duplicates

I have a table with the columns: city, x, y I need to select the distance between all the cities without duplications the results should look like this city1,city2,distance but I shouldn't get city2,city1,distance ( since I already got the distance between those cities... what is the correct SQL query for that... thanks! ...

How do I update records only if I find a duplicate or otherwise insert data?

In the code below there is a hash which contains records with fields like name, pid, type and time1. pid and name are repetitive fields which contain duplicates. I duplicate found update the fields which need modification else insert, here name and pid have duplicates (repetitive fields). The rest are unique. Also I have a unique field...

Practice SQL Queries

Hi I wanted a website that has ample amount of SQL (SQL Server 2005 or 2008) related queries to practice at home Please let me know if you have any idea about the same. thanks ...

Retrieving Data from the Database ASP.NET MVC + Oracle

Hello Friends, I have two tables Users (Userid, Name, PhoneNumber) Applications (ApplicationsId,UserId, ApplicationName, ActiveDate) Every user will have more than 1 application. In Nhibernate using lazy loading I can get the users data along with all the applications for every user. So, I used to do something like user.applications...

Rails form params issue

I'm constructing some data to send over jQuery's $.post, the data that I send looks like this: authenticity_token: LxHlgi1WU8o0DtaNuiQOit/e+HlGR2plVcToHUAhA6I= crews[0][boat_id]: 2 crews[0][crew][]: 10 end_time: 1280408400 start_time: 1280404800 Which is from jQuery converting the data object which is prepared by: creating an array ...

Sending command to SQL Database

Hey All, I am using WinForms & C# to access a SQL Server 2008 on my site which's hosted by winhost.com. I am using the following code to connect to the database, which I figured out for myself: try { SqlConnection scon = new SqlConnection( "My ConnectionString Info is in here."); scon.Open(); MessageBox.Show(scon.D...

SQL command problems (C# Winforms)

Hi All, I am successfully connecting to my sql 2008 server hosted on winhost.com. But I am following this tutorial: http://www.codeproject.com/KB/database/sql_in_csharp.aspx which was suggested in an answer from: http://stackoverflow.com/questions/3357374/connecting-to-sql-server-database-c-winforms and I keep getting the exact same err...

How to insert X amount of rows at the beginning of a pre-existing table of data in sqlite

I am relatively new to sql, so I had a question about insertion. I have a table of data that I need to import above the existing content of another table. For example, the table I am bringing in has 100 rows, and the table I'm bringing the data into has 100. I need to make the table I am bringing new data into have 200 rows, and have the...

How to implement a multi-user tag *voting* system (i.e. like Slashdot's story tags)

Hey all, This is a question that's a bit different from the typical "how do I make a tagging system" question, which has been thoroughly discussed on SO and elsewhere. I want to crowdsource tagging so you don't have to rely on the owner of each document to completely list out applicable tags. At the same time, I don't want a random sch...

Is there a SQL ANSI way of starting a search at the end of table?

In a certain app I must constantly query data that are likely to be amongst the last inserted rows. Since this table is going to grow a lot, I wonder if theres a standard way of optimizing the queries by making them start the lookup at the table's end. I think I would get the same optmization if the database stored data for the table in...

New to android development. Is there an equivalent to Windows Mobile's Datagrid.

I everyone. I'm very new to Android development and I want to develop an application that uses a local database. I want to show the results of queries in a DataGrid like object. The UI would be somewhat similar to this. http://i5.photobucket.com/albums/y163/marco2530/img1.jpg Is it possible to develop this kind of UI in Android? If so...

MySQL: Getting connected (simillar) data with lef/right fields

In MySQL Im having two tables: PRODUCTS (id, Name) SEEALSO (id, prodLeft, prodRight) SEEALSO defines which PRODUCTS are related together and are represented as binded fileds "prodLeft"-"prodRight". For Example: PRODUCTS: 1 Desk 2 Table 3 Chair 4 Doors 5 Tree 6 Flower SEEALSO 1 1 2 2 2 3 3 3 4 4 5 6 From that we can see bin...

How to get difference between 2 columns

I have a query that is producing something like this: StartTimestamp | EndTimestamp ================================ 100 | 450 -------------------------------- 150 | 500 I'd like the result to also include the difference between EndTimestamp and StartTimestamp: StartTimestamp | EndTimestamp | Difference ...

SQL Server Performance of Parameterized Queries with leading wildcards

I have a SQL 2008 R2 Database with about 2 million rows in one of the tables and am struggling with the performance of a specific query when using parameterized SQL. In the table, there's a field containing a name in it: [PatientsName] nvarchar NULL, There's also a simple index on the field: CREATE NONCLUSTERED INDEX [IX_Study_...

Which database(s) should I use?

Hi, I'm building an application that needs to query a lot of data that is written once and not changed anymore. Should I use MySQL for that or should I use something like SimpleDB or BigTable? (I need to write once, read many times) Thank you. Edit: I want to use Heroku, big for me is more than 5MB. "Thousands of rows" take more than ...

How does maps.google.com select and render search result markers so efficiently?

I've been looking into a number of ways to display a large number of markers on a map recently, and thought that Google must have a very efficient solution to this problem (beyond having massive servers!). If you type, say, 'accommodation' into the map search bar, the map shows about 100 or so points (regardless of zoom level), and more ...

Sql Server Xml Column Best Practices

Hi All, What are the best practices for working with Sql server Xml columns to ensure quick performance and also ease of reporting? How do you set up the column? do you leave it as untyped? or associate it with a schema? Does associating the xml column with a schema improve query performance? Our use of xml columns is as follows: ...

Recommended alternative to abusing UserDetailServiceImpl for non-user-related database lookups?

In the project I am working with, there is a UserDetailServiceImpl class which carries out all of the user-related database lookups. The problem is, I have gotten into the bad habit of doing non-user-related database lookups there too and using the UserDetailServiceImpl class as a default lookup service to avoid doing database lookups ...

Use Powershell to create access 2007 Queries?

I have been following Richard Siddaway's Awesome Series on Powershell+Access2007. Unfortunately it ends before discussing creating/running/modifying access 2007 queries in powershell. How could this be done? ...