query

SQL query to get columns and records of that columns using like operator

Hi, I have a table as show below the bold words are column names KEYWORD PART1_D1 PART1_D2 PART1_D3 PART1_D4 PART2_D5 y 1 0 0 0 1 Chinese 3 2 2 1 1 Tokyo 1 0 0 0 1 Japan 1 0 0 0 1 Beijing 0 ...

SQL to combine 2 tables

I have 2 separate queries that returns to me the following tables: =========================== Id f_name l_name =========================== 15 Little Timmy 16 John Doe 17 Baby Jessica --------------------------- =========================== Id item_name item_price =========================== 15 Camera...

Android: how cancel/interrupt/break pending SQLite query?

In my Android application user can fill database with imported data, then perform predefined, complex SQL query. With some data pattern, query will take very long (minutes and more on HTC Hero), while common usage will not exceed 10-15 seconds. Is there any way to cancel pending SQLite query on Android? Timeout would be as good as well,...

mysql query doubt

Hi, my query is as follows: SELECT r.name , r.network , r.namestring , i.name , r.rid , i.id , d.dtime , d.ifInOctets FROM router AS r INNER JOIN interface AS i ON r.rid = i.rid INNER JOIN 1278993600_1_60 AS d ON i.id = d.id AND dtime BETWEEN 1279027200 AND 1279029000 WHERE r.network = "ITPN" AND i.status = "active" WHERE ...

a fairly complex django query

I've got class Supplier(Model) : pass class Customer(Model) : pass class Dock(Model) : pass class SupplierDockAccess(Model) : supplier = ForeignKey(Supplier) dock = ForeignKey(Dock) class SupplierCustomerAccess(Model): supplier = ForeignKey(Supplier) customer = ForeignKey(Customer) I have an instance of C...

What type is this: ISNULL(SUM(COALESCE (a.currency, 0)), 0)

I have the following piece of sql query: Sql += " SELECT ISNULL(SUM(COALESCE (a.currency, 0)), 0) AS monthCurrency FROM IW_Awards AS a "; The query works fine, I am trying to cast this value in C# after the query has been submitted and I cannot find what type it is. I tried int, int? and string. When I trie...

SQL Server 2008 - how to get records that have a specific range of IDs

Hi guys In SQL Server 2008 I would like to create a stored procedure to select specific products, passing their IDs as argument. But I intend to bring as result a range of products. This range must have the informed productIds argument value (for example: 1 and 8 and 29 - that means, the range MUST have productId 1 and productId 8 and...

Filtering a list based on conditions

The problem I have a list of tasks with which a user is greeted with upon login. I want to be able to filter tasks according to assignment. The relevant fields on the table are: **tasks table** task_id | (FK int) user | (FK int) team (assigned to) (assigned to) And users belong to one team. On the front end I have c...

Problem trying to fix SQL query to return a single result

I'm trying to use this query to delete the rows that are already on a linked server's Database: GO USE TAMSTest GO DELETE from [dbo].[Hour] WHERE [dbo].[Hour].[InHour] = (SELECT [InHour] FROM [TDG-MBL-005].[TAMSTEST].[dbo].[Hour]) GO When there is only 1 row in the linked server's table, SELECT [InH...

Querying a subquery

I'm trying to do something like this: SELECT t1.*, t2.* FROM (SELECT * FROM USER) AS t1, (SELECT * FROM t1) AS t2 It doesn't work in MySQL. Is something like the above possible? My other option is to take the last subsquery and "wrap" it around the main query. Ideas? ...

addig char in select statement

I want to add char in Select statement. Ex: SELECT '.' + OUTTRUNK as NUMBER Expected Result: .348977834 .456935534 .090922834 .234999734 How can I do this? Thanks. ...

Is it possible to send variables from HTML to another PHP file

Well I have a index.html where i wud like to submit some coordinates that can be passed upon to separate php file ; where it cud perform a a query. I am new to this and so any suggestions wud be really helpful html: Xmax<input type="text" name="Xmax" size="15"> Ymax<input type="text" name="Ymax" size="15"> <input type=S...

Left Join with where clause

I have 3 tables A, B and C I am doing this :- /* There is no relation between Table A and Table B . Table A is just used to provide values to C.Profile */ 1st step ) D <---- Select * from C where Profile=1 // want to give a specific ProID(I have successfully retrieved it from A table) 2nd Step ) Output <--- Select B.sname,D.Status fr...

How to cache results

I heard that a lot of big project administrators caches results. I wonder how do I do it? Thanks I'm using PHP. ...

Is there a way to upsert a list with a single query?

Hi, I know this question has been asked before, but that's a different scenario. I'd like to have a collection like this: { "_id" : ObjectId("4c28f62cbf8544c60506f11d"), "pk": 1, "forums": [{ "pk": 1, "thread_count": 10, "post_count": 20, }, { "pk": 2, "thread_count": 5, ...

MySQL INSERT - SELECT syntax problem!

INSERT IGNORE INTO table3 (id1, id2) VALUES SELECT id1, id2 FROM table1, table2; What's wrong with the above SQL query? It shows me syntax error. ...

SQL AND on column from join table

I'm having trouble getting the correct results in my query. I'm using Mysql and here is what I have so far: SELECT cpn, status, title, value_category, rating_category, parts.id FROM `vendors` INNER JOIN `vendor_parts` ON (`vendors`.`id` = `vendor_parts`.`vendor_id`) INNER JOIN `parts` ON (`parts`.`id` = `vendor_parts`.`part_id`) WHE...

SQL View Conditional Selection

I am trying to create a view that pulls a particular record. The problem I am running into is that there are 2 records to choose from and a status flag that is either 1 or 2. It should pull the 1 record if it exists, and if not the 2 record. Is this possible from a view? ...

How can I aggregate the # of seconds in a query result?

Hi everyone, I have an Oracle 10g table that contains a # of log records. This table collects data from an environmental recording device that creates a log record every 15 seconds when it is running. I want to add all of the seconds together from the reading dates of the log file entries to ensure that the logger ran > 24 hours (84...

SQL server retrieve table rows based on a single column that contains special/garbage characters

Hi, I have a InsuranceDetails SQL table, one of the column is VIN whose type is varchar(20). Ideally this column should contain only Alphanumeric values (Upper case and lower case allowed) as you might know about a typical VIN number. For some reason this field gets some garbage values during insert. I need to write a query that will g...