queries

Delphi & shared datasources

In my app I have different forms that use the same datasource (so the queries are the same too), defined in a common datamodule. Question is, is there a way to know how many times did I open a specific query? By being able to do this, I could avoid close that query without closing it "every where else". Edit: It's important to mention t...

Problems with More than 1 Left joins in MSAccess

This is related to my previous question More than 1 Left joins in MSAccess The problem is that I have 3 left joins followed by an AND operator to check 1 condition. If I run, then I am getting an error "Join Expression not supported". The query goes like this: SELECT * FROM(( EMPLOYEE AS E LEFT JOIN DEPARTMENT AS D ON E.EID=D.EID) ...

mySQL Select visits and display all by month?

Hi guys, I'm punching way above my weight for mySQL Queries and syntax right now. I could do with some help achieving the following:- I have a metrics/analytics table with country of visit in a row. I have the following query:- SELECT `country`, COUNT(`ip`) AS `cViews` FROM `metrics` WHERE `projID` = 'projID' AND `country` != 'XX' AND...

How to execute SELECT and INSERT in single query with PHP/MYSQL?

I have a table user_name with 3 fields, id, Name, Email (id is auto_increment field). I want to execute the following query in PHP, but its not returning any result. INSERT INTO user_name (Name, Email) VALUES ('Example', '[email protected]'); SELECT LAST_INSERT_ID() AS 'userid'; When I am executing the above query in PHP as below then ...

Intersection of result sets: Existing API?

Suppose I run k-many sub-queries against e.g. tables in a database(s), and the results from each query share a common field e.g. a string, or uuid value, which shares meaning across these tables. Assuming I can have the queries returned sorted, are there API's which exists in languages already which allow me to find the intersection of ...

multiple mysql select queries

I have an array with zipcodes indexed by distance. now i need to select pizza shops based on the zips, some thing like: ziparray[] foreach loop SELECT * FROM location WHERE food='pizza' and zip='ziparray[]' //do stuff The zip array can grow up to 30 or 40 zips in time, which means 30 or 40 querys. Is there a better way to do this? ...

MS Access 2003 - Calculating an average based on qty sold/per site with supply %

Here is another question I have about being able to calculate this scenario in Access, or even at all for that matter: I have a query that find the TOP 5 items sold in a given timeframe, and it groups by site. I use this to create a comparative chart between the site for ppt presentations. I do a lot of these but I have a problem with t...

Tables.Select on Unicode Characters

DataRow[] rows = myDataSet.Tables[0].Select("name = '" + _string + "'"); If _string contains UNICODE characters, do I need to prefix it with N like in TSQL? DataRow[] rows = myDataSet.Tables[0].Select("name = N'" + _string + "'"); Thanks! ...

MS Access 2003 - How can I delete records from a table that have certain criteria

Rookie question I know. I have a table with about 10 fields, one of the fields is a category field. I need this field to exist because of the multiple types of categories. However, one category in this field is wrong and is duplicating results. So can I delete all records in the table that have "Type320" in the CatDescription field, an...

Using multithreading for making queries in Delphi

I've been recently applying threads for making queries to a MYSQL database, I use MyDAC for connection to DB, 'cause TMyConnection doesnot let making simultaneously queries per a connection, I create a new connection and a new query object per every thread executing a query, so in certain time could happens that server has several connec...

Subfolders under Queries in SQL Server 2008 Solution

Can you add subfolders under Queries in SQL Server 2008 Solution? There are large number of query files and it is getting unmanageable. ...

performance of parameterized queries for different db's

A lot of people know that it is important to use parameterized queries to prevent sql injection attacks. Parameterized queries are also much faster in sqlite and oracle when doing online transaction processing because the query optimizer doesn't have to reparse every parameterized sql statement before executing. I've seen sqlite becomi...

JDBC: Is it possible to execute another query on the results of a previous query?

I want to first get some result set (that includes two joins and selection), and then get the maximum value for one of the columns in the result set. I need both the data in the original results set, and the max. Is this possible with JDBC, and how? ...

DataContext.Log equivalent in Entity Framerwork?

In Link-2-SQL, I can use the DataContext.Log property to see the exact queries that are getting thrown to SQL Server. Is there an equivalent to this in Entity Framework? Thanks Daniel ...

SQL, How to query with multiple foreign keys in a table?

Hi there I have a projects table which has two foreign keys for users (user_id and winner_user_id), one for the owner of the project and one for the winner of the project. Something like +----------------+-------------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Defaul...

Workaround for LINQ to SQL Entity Identity Caching and Compiled Query Bug?

I've come across what appears to be a bug in linq to sql where identity caching does not work when performing primary key queries inside of a compiled query. I wrote the following sample to demonstrate the usage of identity caching. It only executes one call to the database the first time it's hit, every time after that it retrieves the...

Is my project open-source if i use .NET langauges ?

I know VB.NET and i want to develop a program. Which i think later will be open-source if i fail to keep updating it. My question is : Is it possible to build open-source project by using .NET languages ? Or do i have to build open-source projects only using open source languages like Java,Ruby, Python etc ? ( I mean is there any restri...

Refactoring in Access Queries

so I have inherited an Access DB with different naming conventions applied to tables. It hurts my eyes, and I want to refactor. Code isn't a problem, but what about SQL embedded in the queries? Going to answer my own question crudely now, but can anyone come up with a better method? ...

sql server questions

i have one question. I have a accttype (varchar) field in t_data table. I have different length acct numbers in that field. like few are 15 digit and few are 13 digit. I just want to know how many are there 13 digit acct no and how many are there 15 digit acct number and list them separately. can any one write sql query for that.Please....

how to erase sql quries from ActiveRecord::Base.logger

Hi All, I'm developing an application using Ruby on Rails. I would like to erase old queries in the ActiveRecord::Base.logger object every time when i call a new action, essentially where ENV = production. the goal is not to erase all queries like using config.log_level :info. i need only last queries to build a file whith those quiri...