query

informix query oddities

Hello, I am running 2 queries against an informix database. the queries are hitting 4 different tables with both inner an outer joins. I thought they should both return the same result set, but I am getting a 3 record difference. below are the 2 queries - query 1 (returns 65 rows) - select ... from table1, table2, outer tab...

Group By and Count using nHibernate

Imagine the following tables : Tag (TagId, Label) Post (PostId, Title, Content) User (UserId, Name) UserPostTag (Id, UserId, PostId, TagId) For a Post, multiple users can add one or more Tag. I want to get, via nHibernate, the tag list for a post, with the count of each Tag. Exemple or result : Tag(id1, label1), 7...

phpadmin mysql change 0 to 1 in a column

Great site, tons of help to me so far. I have a database with 10,000+ rows. There is a column ( tinyint(4) ) called ahtml. I need to change ~500 of the rows for that column from 0 to 1. I know there is a query I can run in phpadmin to do that instead of editing each row. I need to change ALL of the 0's to 1's in the ahtml column. G...

mysql query count per databse

Hi, Im searching a cmdline or any mysql config which can tell me the queries being fired per database. I would check this info frequenty. mysql gives query count but i want it itemized so I can locate which database is more busy more often. Planning to put that code into my munin plugin=chart. thanks, vikas ...

Query with three tables

select record1.fname, record2.fname, record3.fname from record1, record2, record3 where record1.country= record2.country or record1.country=record3.country What is the equivalent query of the above code if you will use inner join and left join? I not yet that familiar with join, but I know how to use join if there are only two table...

Delphi: How to get the query that is passed to the server when parameters are used

I have a query with parameters inside a Devart TMSQuery.SQL. Something like select * from customers where customer = :CustomerID in code I do // Delphi sqlcustomer.ParamByName('CustomerID').asinteger := 4; sqlcustomer.open; I want to debug and see the exact sql command sent to the server, if I try to use TMSQuery.sql I just have th...

MySQL - SQLite How to improve this very simple query ?

Hi, I have one simple but large table. id_tick INTEGER eg: 1622911 price DOUBLE eg: 1.31723 timestamp DATETIME eg: '2010-04-28 09:34:23' For 1 month of data, I have 2.3 millions rows (150MB) My query aims at returning the latest price at a given time. I first set up a SQLite table and used the query: SELECT ma...

How to Display Records from a Database in a Browser?

I'm new to PHP and SQL, and I'm trying to display records from a database in a browser. I'm first trying to test out how to display records when a user selects 'SELECT' from a dropdown menu. created a function called selectById() // function selectById ------------------------------------------------------------------------------------...

MySQL : Does a query searches inside the whole table?

1. So if I search for the word ball inside the toys table where I have 5.000.000 entries does it search for all the 5 millions? I think the answer is yes because how should it know else, but let me know please. 2. If yes: If I need more informations from that table isn't more logic to query just once and work with the results? An exa...

Averaging large amounts of data in SQL Server

It is desired to perform averaging calculations on a large set of data. Data is captured from the devices rather often and we want to get the last day's average, the last week's average, the last month's average and the last year's average. Unfortunately, taking the average of the last year's data takes several minutes to complete. I on...

Complicated daily automatic insert query in 2 tables

I have the following tables with their columns (only the relevant columns are listed): Entry EntryID (int/auto-inc) EmployeeNumber (int) JustifyDate (datetime) EntryDate (datetime) Employee EmployeeNumber (int) CoreHourID (int) WorkingFromHome (bit/bool) Hour EntryID (int) InHour (datetime) OutHour (...

Selecting data from database based on numbers

Hey, guys, I'm trying to figure out how to select data from a MySQL table based of closeness to a number. Here's what I mean. I'm writing an application that stores the coordinates of places (longitude and latitude) what I'd like to be able to do is select data from the database based on the location of where the user is. So, say, for ...

Help with string formatting in SQL Server Query

Hello, I have the following SQL query: SELECT DISTINCT ProductNumber, PageNumber FROM table I am trying to modify the query so that PageNumber will be formatted. You see, PageNumber is in any of the following formats, where 'x' is a digit: xxx, xxx xxx xxx-xxx xx, xxx-xxx xx-xx, xxx xx-xx, xxx-xxx I want to format PageNumber so th...

Sum until certain point from each group - mysql

Hello, I have a MySQL table with about 1000 rows, filled with different types of fruit trees and their locations on a farm. The data looks like this: Fruit Trees Location on Farm 7 | 6 | G G 5 | G Y 4 | G G 3 | A X G G 2 | A A A 1 |_ _ _ _ _ _ _ 1 2 3 4 5 6 7 X Fruit Trees MySQL Tab...

CLlocation Getting best results Iphone

Hello, I'm trying to make a query based on the user location. The thing is that I can only query upon the first location result, with the lat/lon result as the query parameter. How do I make sure I get the best result of a user location and then execute the sqlite query? Thanks in advance! ...

SQL Server 2005/2008 Finding nth highest salary

For Finding nth highest salary I am using select salary from ( select distinct ROW_NUMBER() over (order by salary desc) as rownum,Salary from Employee )a where rownum=2 However if i have same salary like 70000 70000 60000 50000 50000 When executing the query i am getting second highest salary 70000 instead 60000 ...

Can you make this query faster?

Hello! I'm currently doing a summer job and I have to extend an existing program. My boss asked me to make a tool for our clients so they can see how much their employees cost, per month. But that's not all. The thing is that a company can have one or more 'societies', or subcompanies. We want know how much an employee costs per society...

TSQL/SQL 2005/2008 Return Row from one table that is not in othe table

I have to compare a row of one table that is not in another table TableA ID 1 2 3 4 NULL TableB ID 1 4 When comparing TableA with TableB ,the following o/p (NULL Can be ignored) ID STATUS 1 FOUND 2 NOT FOUND 3 NOT FOUND 4 FOUND I tried with SELECT case T.ID when isnull(T.ID,0)=0 then 'NOT FOUND' ...

SQL Query value divided by the max(value)

Hi, I'm ashamed of myself 'cause i can't do this query properly... I have a table like this nom | code_geo | valeur | indice -------+----------+--------+-------------------- AISNE | 02 | 81573 | 0.05 SOMME | 80 | 79520 | 0.03 OISE | 60 | 70004 | 0.09 what i need to do is divide each "indice" by the m...

Lucene.net Query Parser Syntax Problem

Hey All, I'm having a problem building a complicated lucene query using the QueryParser. This is basically what I need to search for one of the fields (allowed): This Field Basically stores some series of keywords that specify some access. It could look like: -PPartners:ALL -PLevel:ALL -PRegion:ASIA, EUROPE, AMERICAS -PAffiliate:GOOGL...