database-queries

How can I optimize a query that does an ORDER BY on a derived column in MySQL?

I am having trouble optimizing a relatively simple query involving a GROUP BY, ORDER BY, and LIMIT. The table has just over 300,000 records. Here's the schema (I added some extra indexes to experiment with): CREATE TABLE `scrape_search_results` ( `id` int(11) NOT NULL auto_increment, `creative_id` int(11) NOT NULL, `url_id` int(...

selecting previous and next rows in mysql - how?

I can't figure out how to select a previous/next row IF the current row does not have any numeric identifiers. With numeric value I always use 2 queries: SELECT min(customer_id) FROM customers WHERE `customer_id` < 10 GROUP BY customer_status ORDER BY customer_name ASC LIMIT 1; SELECT max(customer_id) FROM custo...

Joining columns to rows.

Here's a scenario with a product we purchased. THe product allows us to create custom fields, but these fields are stored as ROWS in a CUSTOM table. I want to write a query that will connect to more than one custom field and fetch a single row. Let me give you an example. 1) PERSON TABLE (ID int, NAME varchar2(30)); 2) CUSTOMFIELDS TA...

XML and its uses in Databases

what is XML and how is it used in databases? if this looks like a homework assignment,it is. ...

Multi SQL Queries in associative array with PHP/SQL

I've got a very simple question about sending multi-queries with php/sql and add each result in an associative array. Basically, I've assigned each query in an associative array. Each result for each queries go into my multi-dimensional array $el['nameofthequery']['resultsofthequery'] //connection information $host = "localhost"; $u...

Oracle: LONG or CLOB?

From these two threads, Why is LONG an issue with Oracle? Is it possible to read a CLOB from a remote Oracle database? LONG is archaic and deprecated. Oracle says, Do not create tables with LONG columns. Use LOB columns (CLOB, NCLOB) instead. LONG columns are supported only for backward compatibility. Oracle also recommends ...

SQL update query

Say I wanted to perform an update in a database that held information on for example cars in a table by that same name. The update I am looking to perform consists in changing the designation in the table in model from "Ford" to "Ford-" i.e. only changing where the designatin is "Ford" and not in those that already have a model design...

How does a bitmap index work?

Is there anyone can help me to get the logical represntation of a bitmap index and reverse key index? ...

Transfer column data from one database to another

Hello, I'm trying to transfer an entire column's worth of data from the backup database to the current production database (earlier in the day I had ruined this column in production with a bad update). I am using MS SQL Server 2005. In this example, I am trying to restore 'Column1' from DB2.Table1 into DB1.Table1: begin transaction ...

Is there a very simple front-end for MySQL tables?

Hi, I'm looking for a front-end that's very simple, to access a to-be-built MySQL Database. I actually need it for only one table. I was thinking that the user could search in a way that would ask for values for each field of that table, and give the option of leaving it blank. Then, it would return all the entries that match up with th...

Django / Python, getting field name from database get object?

Sorry if I'm missing something obvious here as my search isn't turning up anything relevant. I am doing a Django database get query and would like to get each field name during a for loop so that I can do evaluations of it ( if fieldname = "blah") and so on, but I can't seem to figure this out, any advice is appreciated db_get_data = Mo...

GAE in java: Get position in highscore database

So I am trying to implement a global highscore for my game in google apps engine java. The information I want to retrieve is twofold: Which position did the user place? How many percent of all records did he beat? The second question is solved if I solve the first one, and find a way to count the total number of rows in the database....

How do you join a query between 2 databases involving sys tables?

-- find last usage info, -- how far back this information goes depends on the -- server/database settings select -- ss.name as SchemaName, so.name as SprocName ,so.create_date as SprocCreated, so.modify_date as SprocModified ,so.object_id ,stat.last_user_seek,stat.last_user_scan,stat.last_user_lookup,stat.last_user_update ,stat.last_...

Database Toolbox (sql-matlab) randomly returning different values for only windows 7 computer

Hey, So I am trying to use the database toolbox in matlab to query a database at my research lab, and on one specific computer, the results it returns from the same query changes each time you run the SAME query command. connPV = database('dbname','username','password'); Images = fetch(handles.connPV,['SELECT i.id, i.image_type_id, i...

Loading database at start up slows down the app...

Hello, i m not sure how to describe this as i m new with all the developing and i m really looking forward to an answer from you guys. I know you can be very busy but please try to HELP me! Here it goes. I have an app that loads a very large database (although it only has 100 entries it contains HiRes images (100MB) ). At start up a ta...

How to search keyword in 100 billions of posts ?

This is a college project: I have a database ( mysql or postgresql doesn't matter ) with 100 billion of posts and I need to search ( as fast as possible ) a generic keyword. Every post is 500-1000 keywords. This isn't only a database issue but also a software ( for indexing or other ) issue. How can I do that ? I could use some adva...

How can I SELECT+INSERT in the same mysql query?

I have a php script that process keywords from a mysql table "keywords" (columns: id - keyword) and then it saves data into another table "data" (column: id[foreign key keywords.id] - dataname - datavalue). My problem is that when the script is ready to save the data I only have the keyword and not the id. So is there a way I can get t...

SQL query help, conditional join

Hi guys, SQL newbie here :) Here are my tables if anyone's interested. AHH, cant post image yet http://img832.imageshack.us/img832/442/72098588.jpg What I'm trying to do is query the tblPatientStats table within a date interval (@StartDate, @EndDate) and group them accordingly in a data grid on winforms. So each row in tblPatientSta...

What's needed to develop a database in the cloud?

What is needed (in general terms) to create a service like MongoHQ or SimpleDB? Thank you ...

SQL Server 2005: Insert missing records in table that is in another reference table

Hi to all, I need help with the following. I have 2 tables. The first holds data captured by client. example. [Data] Table PersonId Visit Tested Done 01 Day 1 Eyes Yes 01 Day 1 Ears Yes 01 Day 2 Eyes Yes 01 Day 3 Eyes Yes 02 ...