sql

ORM for Javascript/JSON

I am working on a web application that gets JSON data from the server (Ruby/Rails) into the client using jQuery/ajax and then renders it to the browser using jQuery to populate the DOM. To simplify access to my data on the client side, I would like to use an object-relational mapper similar to ActiveRecord, but which starts with JSON dat...

MYSQL why would min be larger than max?

select min(lead), max(lead) from products WHERE part_line != 90 and category = 'x' When I run the above query the min returned is larger than the max. If I remove the condition pline != 90 the problem goes away. I was thinking at first that mysql was processing the min, max before it got to pline... but that doesn't explain why it w...

ORA-07445 access violation

I have this error when running a large query on oracle. any advice? I'm using pl sql version 10.2 I have noticed that the error is due to creating a view that is based up on many tables, and when I do a select from this view to a specific parameter with a where condition I got that error. When I checked the logs I found out this o...

SQL Type-casting

I'm dividing some integers x & y in MS SQL, and I wan the result to be in a floating-point form. 5/2 should equal 2.5. When I simply do SELECT 5/2 I get 2, which doesn't suprise me, since it's creating an int from two ints. I know I can force it to a float by doing: SELECT CAST(5 AS FLOAT)/CAST(2 AS FLOAT); but that seems like ...

SQLCommand.ExecuteReader() does not restrict to read only statements

So apparently, ExecuteReader is used for read only and ExecuteNonQuery is used for transactions. But for some reason even when I used ExecuteReader I am still able to run write (Insert, Update, Delete) commands (typed in textbox1). Is there something wrong with my code or am I misunderstanding the way ExecuteReader is supposed to work? ...

Select TOP #CHUNKSIZE# ....

I haven't seen this before in a query, basically what is going on here? ...

Trace a Hierarchy in a Table

Hi I have an "Employee" table with an "EmployeeID" column and a column representing Employee's Boss (BossID) which in turn is an employee in the "Employee" table. How can I trace the hierarchy from a given "EmployeeID" to the top most Boss. I do not want a self join approach in this, also I am using SQL Server 2005. Thank you Man...

How can I add other columns from a foreign table in the sql?

See the tables structure here. I have this sql: SELECT `feed_entries` . * FROM `feed_entries` WHERE id IN ( SELECT `e`.`id` FROM `feed_entries` AS `e` INNER JOIN `feeds` AS `f` ON e.feed_id = f.id INNER JOIN `entries_categorias` AS `ec` ON ec.entry_id = e.id INNER JOIN `categorias` AS `c` ON ec.categoria_id = c.id WHERE e.deleted ...

is it common practice to further manipulate query results in code

I am not very experienced with either programming or scripting database queries, and I have seem to come to rely on further manipulation of results from a database instead of spending time writing a more complete query that would achieve my final objective. In fact in some cases I am completely changing the nature of the results by c...

How to limit results of a LEFT JOIN

Take the case of two tables: tbl_product and tbl_transaction. tbl_product lists product details including names and ids while tbl_transaction lists transactions involving the products and includes dates, product-ids, customers etc. I need to display a web-page showing 10 products and for each product, the last 5 transactions. So far, n...

PHP with SQL Server: strtotime() with SQL Server DATETIME column

So I have SQL Server datetime field, and in PHP I want to use this as a UNIX TIMESTAMP, because I want to use it with strtotime, in order to add 14 days into it. Eg. If it is stored in the SQL Server database as: 2010-07-27 13:12:22.040 I want to add 14 days into it to become 2010-08-10 13:12:22.040 How would I do that using PHP wi...

How to build a query to divide a field based on another field?

I want to get cases of wine where each bottle is between $4 and $8. The costs in the products table are all in cases of 12. Easy huh? SELECT `id` FROM `products` WHERE (`cost` / 12) > 4 AND (`cost` / 12) < 8 Now, they are beginning to sell cases of 6. Assume that this is defined only in the title string with 6 pack. How do I w...

SQLite : finding a function's minimum values

Hi folks ! I have those tables Node (#id, route_id, lat, lng) Route(#id) And I have four input values : $lat1, $lng1, $lat2, $lng2, which represent 2 GPS coordinates GPS1 and GPS2. I also have a distance function that I added to the database : distance( lat1, lng1, lat2, lng2) What I am looking for is the request that will give me ...

How to avoid ODBC parameterization for the question mark character ? within literals and comments?

I'm running into an issue where I have question mark characters '?' within my SQL scripts inside comments is causing problems. When I run these statements through an ODBC connection using the Visual FoxPro SQLEXEC function these characters are being seen as parameters and VFP prompts for values. What are my options for dealing with ques...

What is wrong with this SQL statement?

I'm trying to create this table and I want to gauge my eyes out. What is wrong with it? I get an error: "Incorrect syntax near PLAN" create table Instrumentos( ID int primary key, IDSeguimiento int foreign key references Seguimiento(ID), GuiaDocente bit, GuiaDocenteObservacion varchar(200), GuiaAlumno bit, GuaiAlumnoObservacion varchar(...

SQL Reporting 2008 Multiple tables repeating on each page

Hey Guys Ive got a report that has 2 tables, Table1 & Table2. Table1 can have up to 5 rows and then needs to continue on the next page. Table2 which sits below Table1 also needs to be shown on the next page as well. I can get Table1 restricting its records and page breaking to another page though the issue is getting the second table ...

Condition text field character insert with SQL Update statement

I need to update a field in a SQL-Server table conditionally. The field contains single-letter indicators of various status types, all together in the field. e.g. "I" for Insured, "O" for Other Insured, "H" for Health Qualified, etc., but together as a composite. The field might contain nothing, any of the letters, or all of the letters....

hibernate see slow query

inside hibernate.property. is that any parameter i can set to see all the slow query that take too much time to return result? i'm using spring-hibernate applicationContext.xml ...

SQLite android login and register

From the previous question I asked, I am still having the same question. I do not know how to use database (SQLite) to 'sync' with my application to log in or register package log1.log2; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickLis...

Problem with writing an SQL Sub Query

I know I must be missing something simple here...but I'm having problems with writing an SQL sub query. Given the following data user_id question_id answer_text 89 1 value1 89 2 value2 80 2 value2 99 2 value2 96 1 value1 96 2 ...