query

Command parameters are unsupported with the current provider - What do I do?!

I'm trying to query the Microsoft Indexing Service catalog, and I've found a bunch of really helpful articles about it (like this one), but every example I find they just use string concatenation to build queries, and it feels so wrong on so many different levels. I clearly want to use parameterized queries, but it looks like the MS Ind...

How to do find() with includes() in Rails 3

I'm trying to do something like this, but it's not working. How would i do this in Rails 3? Student.find(12).includes( :teacher ) ...

How can I improve the performance of this MySQL query?

I have a MySQL query: SELECT DISTINCT c.id, c.company_name, cd.firstname, cd.surname, cis.description AS industry_sector FROM (clients c) JOIN clients_details cd ON c.id = cd.client_id LEFT JOIN clients_industry_sectors cis ON cd.industry_sector_id = cis.id WHER...

Getting the "Closest" Value out of the Datastore

What is the recommended (read most efficient) way to obtain a single entity out of the datastore based on a value that's closest to one provided. For example, I have the following DataModel: class MyObject(db.Model): someValue = db.IntegerProperty() shortDescription = db.TextProperty() During a GET a value is passed in, I wou...

Please help merging 4 MySQL queries to One.

UPDATE RIA.Contact SET title = REPLACE(title, 'Cheif', 'Chief') where title rlike 'Cheif'; UPDATE RIA.Contact SET title = REPLACE(title, 'Manger', 'Manager') where title rlike 'Manger'; UPDATE RIA.Contact SET title = REPLACE(title, 'Manging', 'Managing') where title rlike 'Manging'; UPDATE RIA.Contact SET title = REPLACE(title, 'Excutive...

T-Sql - Pivot Error

I have the following code in a T-Sql query, I am getting the following error message and I am not really sure what is causing the error. I am writing the Pivot statement to be dynamic b/c I do not know the columns that will be returned. Error Message: Msg 8156, Level 16, State 1, Line 9 The column 'Title - Endorsement Fee / END8' was s...

Filter database results without running an additional query

I'm using CodeIgniter for a classifieds website. Here's a specific example of what I'm trying to achieve: On page http://www.example.com/browse/Real-Estate all the Real Estate classifieds are listed. I'm using CI's Pagination Class to paginate the results. On the leftbar, a set of filters are shown that correspond to each db column of ...

Join + Count per row in postgresql

Current "Attempts" table: ID QUESTION_ID CORRECT 1 1 FALSE 2 2 TRUE 3 4 FALSE 4 3 FALSE 5 1 TRUE 6 1 TRUE 7 4 TRUE 8 3 TRUE 9 4 FALSE 10 1 TRUE 11 2 TRUE 11 1 FALSE 11...

Mysql Query Left Join Condition Problem

hi, I have a litte problem with a mysql query. I use 5 tables: user_has_data (uid, dataid); users (uid, uname); user_in_group(uid, groupid, data); groups(groupid, data, packageid); packages(packageid, name) all ids are PK. I want to build a sql query that finds a user, which belongs to a specified dataid, by its uname and checks if t...

'and' terms not reversible in Sitecore Fast Query?

This one may be a bug, or it may be me failing to understand something. Assuming there are some named 'Profile' items inside /sitecore/system/marketing center/profiles, this query returns all of them (tested in XPath Builder): fast:/sitecore/system/marketing center/profiles/*[@Name='%' and @@templatename='Profile'] But if I reverse t...

Query a Subquery

I have to display the Rank of a user for which I plan to use the Rank() function in SQL Server. The Sql query to get the rank is as follows select a.user_id, RANK() OVER (ORDER BY (a.quant_points) DESC) AS QRANK, RANK() OVER (ORDER BY (a.verbal_points) DESC) AS VRANK, RANK() OVER (ORDER BY (a.dilr_points) DESC) AS DRANK, RAN...

Is multiple named query file possible

I always see a single file being used for named query. I have never seen multiple file for queries, but can it be done? ...

How can I optimize this wordpress mysql query?

I have a mysql query which is really bogging down my VPS. Its doing a filesort according to explain extended. I usually optimize queries on my own but this one i'm not sure I know how. SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_posts.*,MAX((1.00 * (MATCH(wp_search_post.post_content) AGAINST ('test' IN BOOLEAN MODE))) + (2.00 * (MATCH(wp_se...

Use query strings with Pagination Class in Codeigniter

Is it possible to append query strings to the links created by the pagination class? Currently if you are on this page: http://127.0.0.1/~panayi/xryses/Nicosia/browse/Homes?price_low=19&price_high=300 the links are incorrectly generated as http://127.0.0.1/~panayi/xryses/Nicosia/browse/Homes&per_page=20 http://127.0.0.1/~pa...

Best way to query multiple 'categories' mysql php?

I am probably overlooking something simple-- Some of the news items has 2 categories checked, and other times it has all 4 check. I know I can do OR '' OR '' OR '' OR '' -- but I think there is a better way. The question: How could I query this to output: if the story has category 10,13 or 10,13,15 or 10,13,15,16 or 10,15 or 10,13?? ...

SQL - Need help build a select query

Hi I've a table (hosted in a database SQL Server) where i've products stored. The person who inserted a few products last week, instead of making new lines with "Enter" (tinyMCE would created a </br> tag) in description, she had typed "Space" creating white spaces (she though that typing white spaces, creates new line when it goes to th...

PHP MySql query to delete rows doesn't work.

I have this php script: foreach (get_all_topics () as $topic_id => $topic_info) { $result = mysql_query("DELETE FROM marks WHERE user_id = $user_id AND topic_id = $topic_id", $db); echo "DELETE FROM marks WHERE user_id = $user_id AND topic_id = $to...

Redefining :all

I have users in my system that can elect to 'hibernate', at which point they can remove themselves and all of their associated records entirely from the system. I have queries all over my site that search within the User table and its associated tables (separated by as many as 5 intermediate tables), and none explicitly test whether the ...

Select Query is not working with WHERE clasue when there is a space in Column Name

I have got SQL Server database in which Table column name have spaces. For example I have a Table something like this: ID| First Name| Last Name|Birth Date 1 | Wasim | Akram | 01-01-2000 2 | Saeed | Anwer | 01-01-2001 Now When I use a following query(column name with space) I get empty result: SELECT * FROM table WHERE...

Refactoring sql into regexp - Microsoft Access

I'm not a pro with regexp and especially in this specific context. Any idea how to use a function to do a RegExp Replace and then calling it from the query in Microsoft Access? By the way, this query oddly enough doesn't work fully and maybe it's why this could use regexp. The idea is to match the three fields in the temp_table query:...