query

SQL queries not in one place but assembled dynamically while passing through several system layers. Is this a good practice?

I personally find that makes the life of a developer who has recently joined the project a very sad one. Without almost perfect understanding of the framework mechanisms it makes developing and debugging like a torture, since whenever I get an error or an unexpected behavior I have not a slightest idea where to look. In some rare cases C...

In VBA how do you return the name of an underlying query for a report object?

I would like to obtain the name of a query behind a specific report. I was hoping to do something like this... Dim QueryName As String QueryName = CurrentProject.AllReports(MyReportName).RecordSource.Name However, I know this does not work, but I would like to find a means of doing this. Is there something I am obviously overlooking...

MySQL Query

Hi, I new to the MySQL syntax. I have created a procedure and ran it, but it is showing some syntax probem, can you help me? My procedure is as: **DELIMITER $$ CREATE PROCEDURE TestAdd( in mODE varchar(10), in Id int, in AttName varchar(10), in AttValues Varchar(10) ) IF EXISTS (SELECT * FROM AttTable WHERE id=Id) THE...

Getting only one row in outer join using oracle

I've got a table and want to outer-join another table, getting only the first row (the one with lowest nr) of the second table using Oracle 10g. Edit: nr is unique within an id Table x Table y id id nr code 1 1 1 B 2 1 2 A 3 2 2 A Expected result: id nr code 1 1 B ...

issue performing a very specific SQL query to place data in a different format

Hello, I am having some trouble dealing with an SQL table that needs to be queried and re-formatted into another table for reporting purposes. Here's the initial table: id int, logtimestamp datetime, serialnumber varchar(255), robotid int, amountconsumed float The robotid's are only from 1 to 4. Eve...

MySQL: Retrieve Unique Values and Counts For Each

Is there a simple way to retrieve a list of all unique values in a column, along with how many times that value appeared? Example dataset: A A A B B C ... Would return: A | 3 B | 2 C | 1 Thanks! ...

Looking for a PHP query designer framework

I have a client that wants to move their users from MS-Access to a PHP/MySQL web application. The data has already been migrated to MySQL and, thankfully, there are no Access forms, just queries. What they want me to do is build some kind of querying framework where users can build queries, save them, filter/drill-down results, sort by...

Implementing a Blacklist of keywords in SQL

I have a list of keywords (strings) in which I need to identify any matches with a blacklist of keywords (strings in a separate table) Any keyword/blacklist matches will be flagged in a bit field: Keyword.IsBlacklisted. Is there an easy way to accomplish this in SQL? The matches might be partial (i.e. blacklist = 'sex' keyword = 'sex ...

How to query multiple entities at once?

I'm trying to query an Entity to return multiple rows based on a filter. For instance in SQL we have: SELECT * FROM table WHERE field IN (1, 2, 3) How do I do it in LINQ to Entities? ...

How can I write my SQL query in LINQ?

I have a table that looks like this. The query needs to return the last date entry for each location. How would I write this in SQL and LINQ? Id Location Salary Date 1 Los Angeles $1500 Jan-05-1999 2 San Diego $250 Jan-07-1999 3 Los Angeles $300 Jan-08-1999 4 Boston $700 Jan-08-1999 ...

group by first character

hello friends i have a problem in oracle -sql. i have a query please solve out it i have a column first_name in employees table. i want to group my records according to first character of column first_name. like if i have 26 name from (A-Z) in column first_name then there should be 26 group according to alphabates. i tried following...

How can I tell a database to only return data in discrete portions?

I couldn't find a proper discussion thread on this topic, so I'm going to go ahead and ask here. Problem: I have a select query that returns a result of size 100,000+. The user wants to view all this data, but obviously I can't give it to him all at once. I also don't want to store so much data on the client's memory. I want the user to...

Is it possible to run arbitrary queries with Linq to SQL? (C#)

How would I write the following query using Linq to SQL? UPDATE [TB_EXAMPLE] SET [COLUMN1] = 1 (My actual goal is more complex than this) ...

Find newest objects in ActiveRecord

Easy question: I need help writing an ActiveRecord find_all_by statement where I want to order things from newest created objects to oldest. As a follow-up to this question: If I saved the results into a variable @records. How do I then ask for the next record in it? I want to do something like @current_record = @records.next ...

Freebase MQL query for topic summary and image?

I'm trying to write an MQL query to be executed using Freebase API's. I would like to retrieve the topic summary and the image for the topic. I have been able to work out the below query which will get me the images associated with the Bill Gates topic. MQL: [ { "/common/topic/image" : [ { "id" : null } ...

MySQL ORDER problem

I have a pretty simple SQL query but something is missing and I didn't find an answer for this problem yet. The thing is that I select some fields with several ids and I want the result to be ordered in this particular order. The query is the following SELECT `content`.* FROM `content` WHERE (user_id = "1" AND ( id = "4" OR id = "...

Freebase MQL filter where value != null?

I'm trying to write an MQL query that filters out null values. The query I have now (can be executed using the MQL Query Editor): [ { "/common/topic/image" : [ { "id" : null } ], "article" : [ { "content" : null } ], "name" : "bill gates", "type" : "/common/topic" } ] ...

Mysql, Possible Nested Category problem

I have a mysql question. I have an application which I am migrating to PHP/Mysql from Coldfusion and MSSql. There are categories and sub-categories (with apparently unlimited sub-categories). What is the best way to grab all of the records in a products table given a navigationID. there are two tables I am dealing with. One is the P...

SQL backlog calculation (MS Access)

Hi, I need to calculate the backlog from a table: components(ProductId, ComponentId, Status, StatusDate) where ComponentId, Status and StatusDate are the primary key. ProductId is a foreign key. Example: prod1, comp1, 01, 05/01/2009 prod1, comp1, 02, 05/01/2009 prod1, comp1, 03, 06/01/2009 prod1, comp1, 01, 07/01/2009 prod1, comp1, ...

How to provide a SQL command line interface (like osql) to a MSSQL database via webpage in .NET MVC (c#)

I'd like to provide a command line interface to my db that allows the user to enter MULTIPLE database commands or queries (separated by line breaks in the textarea) For each line, if its a query must return the results and if its a command, whether or not it was successful - thus allowing the user to paste a script into the text area an...