query

Select mysql query between date?

How to select data from mysql table past date to current date? For example, Select data from 1 january 2009 until current date ?? My column "datetime" is in datetime date type. Please help, thanks Edit: If let say i want to get day per day data from 1 january 2009, how to write the query? Use count and between function? ...

How to properly test query performance

I have a function that takes either an array of IDs or a singular ID as an argument. If an array is passed, it is imploded on comma to make the IDs query friendly. There is a query inside this function that updates the records for the IDs that were passed. The query is as follows: "UPDATE tbl_name SET enabled = 1 WHERE ID IN (" . $ID...

Hibernate query by example (from Spring 3)

I've made my entity classes Adress, Road and County. A Road is in a County and an Adress in on a Road. I would like to list all the Adresses in a County. Therefore, in my AdressService I say: public List<Adress> AllAdresses(County county) { Adress adress = new Adress(); Road road = new Road(); road.setCounty(county); adress.setR...

Select query with no duplicate "First Letter" in sqlite

How can I select data with no duplicate the "First Letter" value? My table has a column named "title_raw" with data arrange follow "A, B, C, ..." I want my data display something like this Select (title_raw no duplicate first letter) from SONGS ...

Any benefit to deleting a soft-deleted row in MySQL?

I have a table in MySQL dB that records when a person clicks on certain navigation tabs. Each time it will soft-delete the last entry and insert a new one. The reason for soft-delete is for analytics purposes, so I can track over time where/when/what users are clicking. The ratio of soft-deletes to new entries are 9:1, and the table size...

SQL Query (Like) Trying to find Titles with AND

When doing a SQL Query and I want to pull up entries from a table that have AND in the name, but I do not want names that just have and in them..... Confusing, but I'll show an example 2 Entries in the table : Pandomniam, and Frank and Beans. When I do the query I just want Frank and Beans to come up, not Pandomniam. I am doing som...

sql query taking too long

Hi, I have simple "insert into.." query which is taking around 40 seconds to execute. It simply takes records from one table and inserts into another. I have index on F1 and BatchID on the tbl_TempCatalogue table 146624 records are effected. select itself is not slow insert into is slow. The complete query is insert into tbl_ItemPr...

Easier way to insert a long array into an INSERT query?

I'm trying to insert this array into a database: Array ( [0] => 1 [1] => 2376 [2] => 1804229942 53 [3] => 99 [4] => 120510105 5525 [5] => 99 [6] => 21581237 622 [7] => 99 [8] => 46612404 3 [9] => 99 [10] => 174284497 8 [11] => 99 [12] => 200000000 922 [13] => 99 [14] => 13641206 5 [15] => 99 [16] => 118438707 15 [17] => 99 [18] => 20000...

Query tool for Oracle 9

I'm used to the comfort of working with MSSQL and the Enterprise Manager and Query Analyzer. Now working with Oracle 9.2 and having to suffer using SQL Plus for making queries, I'm looking for some better alternatives. Are there any free or low-cost tools for this purpose? ...

How to get the biggest differences between two fields comparing all users?

I have a table that has the columns skill1xp, skill1lvl, and skill1rank for 25 skills. Each day I update it for all users, so there's a datetime column. I'm making a high-scores progress tracker for a game, for many users, and I've got just one feature left, which is Highest Gains for a certain period of time (day/week/month). I guess t...

MS Access. Editable Selection. Grouping of Items based on data other than primary key.

I hope I can explain this clearly. I have a table, lets call it Widgets, that contains information (Color, Size, etc) about many many different widgets that are specified by an ID# which is the primary key. I also have a table, call it Tests, that is related to Widgets through a one to many relationship. Each row in this table represen...

How should I handle query synchronization in PHP?

I would like to insert some value into a table, which has an auto-incrementing field as a primary key. Then I want to retrieve the ID by using mysql_insert_id() and use this ID as a foreign key in another table. The problem is - although very unlikely - it may happen that between the first insertion and the later retrieving, another inse...

SubSonic - Using Sprocs vs in-line code-behind query?

I'm curious about at what extent I should be writing sproc's. Obviously for actions that require transactions, etc. However for a simple validation against one table and values within, is it still recommended to use a sproc rather than doing the SubSonic query in the code-behind? In one respect it does make sense to write the sproc, a...

C# Xpath Query to find a single Node

I want to find a simple element (Name) in an XML : <ZoneContentMapping> <ZoneContent> <ContentId>72503</ContentId> <StorefrontZoneId>Name</StorefrontZoneId> <Type>ContentZone</Type> </ZoneContent> </ZoneContentMapping> I am doing : XmlNodeList objNode = objXML.SelectNodes("ZoneContentMapping/ZoneContent[Content...

automatically set the value of one variable depending on another variable's value in sql table

I am new to sql and How can I automatically set the value of one variable depending other variable's value. I have price in foods table, and in orders table I want to change the total value of the price according to the # of orders for a specific food. ...

MySQL: Unknown column in where clause error

I have a PHP script and for some reason mysql keeps treating the value to select/insert as a column. Here is an example of my sql query: $query = mysql_query("SELECT * FROM tutorial.users WHERE (uname=`".mysql_real_escape_string($username)."`)") or die(mysql_error()); That turns into: SELECT * FROM tutorial.users WHERE (uname=`test`)...

MS Acess 2003 - VBA for Update SQL query?

hey guys, could someone show me the simple update query through vb? I need to add new fields to the table (just 3) and add a couple text boxes on a form so that users can add some additional data relative to the record (which is already what this form is based on). So the first form I have is a form that populates a list, when the user ...

SQL query is only retrieving first record.

Hi, I have a query which is designed to retireve the "name" field for all records in my "tiles" table but when I use print_r on the result all I get is the first record in the database. Below is the code that I have used. $query = mysql_query("SELECT name FROM tiles"); $tiles = mysql_fetch_array($query); I really cant see what I have ...

(Rails) Visually representing multitiered complex queries...?

Hi All, So I have a bit of a problem. I need to set up dynamic queries with a particular group of "entities" in Rails. And I need multiple levels for each item. Basically this particular entity relationship is as follows: CHART has many POINTS POINTS belong to many CHARTS Now, when it comes to displaying CHARTS, the application wil...

Finding record in mysql table that has the highest value

Hi, I want to be able to seach in my table named "map" to see which record has the highest value for "positionV". For example if I had 5 records in "map" table and under "positionV" the values for each were, "3, 8, 9, 2, 10" I would wont it to output 10. I am using PHP also by the way. ...