query

Running a query with PHP/MySQL then reordering the results by another column.

This SQL query gives me the results I want; however, I want the results ordered by a different column: SELECT * FROM post INNER JOIN account ON post.account_id = account.account_id WHERE post_id > neww ORDER BY post_date ASC LIMIT 10; I can not simply change 'ORDER BY post_date ASC' to 'ORDER BY post_id DESC', while that will...

What's the best way to retrieve this data?

The architecture for this scenario is as follows: I have a table of items and several tables of forms. Rather than having the forms own the items, the items own the forms. This is because one item can be on several forms (although only one of each type, but not necessarily on any). The forms and items are all tied together by a common O...

SQlite query question, importing multiple records

Ok, so I am making progress since my last question. My question now is a lot more simple, or at least I understand more clearly what my question is. In my AppDelegate I have this code to read in data from my database: -(void) readFromDatabase { // Setup the database object sqlite3 *database; // Init the Array sections = [[NSMutableArra...

unicode string search

i am using Postgre sql database in my database there is one table mumbaipropertydetails in that one column zone has unicode data. when i execute query select mumbaipropertydetails."zone" from mumbaipropertydetails; it gives output like this. "\u092A\u093F\u0902\u092A\u0930\u0940 \u0935\u093E\u0918\u0947\u0930\u0947" "\u092A\u093F\u090...

like Query using plsql database for unicode string.

This gives the correct result select name_en,address_new,ddress2_new,unique_id from mumbaipropertydetails where mumbaipropertydetails."zone"='\\u092E\\u0928\\u092A\\u093E \\u092D\\u0935\\u0928'; but if I use like it does not select name_en,address_new,ddress2_new,unique_id from mumbaipropertydetails where mumbaipropertydetails....

Find best matching row in MySQL (InnoDB)

I have the following test string engine/mail/key and a table which looks like this: +-------------+ | query | +-------------+ | engine | | engine/pdf | | engine/mail | +-------------+ I want to find the best matching row. Best match is specified by the most matching characters from the start of the string/row. I have con...

MOSS 2007 Displaying contents of a folder using the Content Query Webpart

Hi, I'm trying to display a certain folder's content using the Content Query Webpart. While I'm perfectly able to display either all files in the document library (parent of the folder) or just the folder(s), I fail to understand how you would display a certain folder's content. Can anyone please enlighten me? ...

How to do an INNER JOIN on multiple columns

I'm working on a homework project and I'm supposed to perform a database query which finds flights either by the city name or the airport code, but the flights table only contains the airport codes so if I want to search by city I have to join on the airports table. The airports table has the following columns: code, city The flights ta...

Mysql 5.1 on Mac: query cache not working

Hi, I was wondering if someone could point me in the right direction. I have set up a local Mysql 5.1 sandbox on my Snow Leopard OSX machine, I have the Macports Mysql 5.1 installed and, by all appearances, functioning. It takes queries, the database is working, etc. The only strange thing is, the query cache isn't functioning. I have ...

How to update a database record and still keep the old values in MySQL?

I want to update a column by adding a new value alongside the old ones. So if column "fruits" has a value of "apples" and I run my query it should then have a value of "apples, oranges". Right now when I do an update statement" UPDATE tableName SET fruits='oranges' WHERE id=1; It just overwrites apples with oranges. How can I get it...

three20 - can the query added to an openURLAction also be passed back to the parent

I am setting up routing to a TTTableViewController as follows: [map from:@"myurl://filter/(initWithName:)" toViewController:[FilterViewController class]]; and then, in another view controller I set up a mutable dictionary to pass through as my query: // Set up dictionary and populate a field NSMutableDictionary *filterDictiona...

Ordering results by computed value in Hibernate

Hello, I have a table Player with columns id, name, wins, games_played. I mapped it to a class Player. I want to do the following query in Hibernate (preferably with Criteria, if not possible with Criteria HQL will also help) select * from Player order by (wins / games_played) I expect to get List<Player> sorted by their win rat...

Python: Fast querying in a big dbf (xbase) file

Hi all, I have a big DBF file (~700MB). I'd like to select only a few lines from it using a python script. I've seen that dbfpy is a nice module that allows to open this type of database, but for now I haven't found any querying capability. Iterating through all the elements from python is simply too slow. Can I do what I want from py...

Django Query in a loop fails for no good reason

Hi all, I have this code: msgs = int(post['time_in_weeks']) for i in range(msgs): tip_msg = Tip.objects.get(week_number=i) it always results in an error saying that no values could be found. week_number is an integer field. When I input the value of i directly, the query works. When i print out the value of i I get the expected ...

Optimizing simple SQL query?

Greetings friends, In my MySQL database, I have 'MAB' table which contains information about Gene Ids (GI_ID),and some other gene related information. 'MAB_CAN' table can contains the Gene Ids (GI_ID) only relevant to Cancer. I use following SQL query to get cancer related information from MAB table : SELECT * FROM MAB WHERE `GI_ID` ...

Remove Expired Records in solr query syntax

Hi, I'm having a solr query syntax issue (I think) with solr 1.4. I'm trying exclude expired records from a solr query. However if the record doesn't have an expiry record, i would like to bring that record back also. E.g. To only get a list of record that haven't expired i am using this query: expirydate:[NOW/DAY TO *] Then I thoug...

Writing 'CONTAINS' query using LINQ

Given the output of query: var queryResult = from o in objects where ... select new { FileName = o.File, Size = o.Size } What would you consider the neatest way to detect if a file is in the queryResult? H...

how to do union of the following two queries

Am trying to do the union of the results of two queries. But I'm getting the following error: Error at Command Line:9 Column:81 Error report: SQL Error: ORA-00907: missing right parenthesis 00907. 00000 - "missing right parenthesis" SELECT application_id, clicks, datee, client_id FROM( (select APPL_CD AS application_id, count...

Like and Where in the same MySQL query

I would like to use something like the following: SELECT city FROM cities WHERE city LIKE %D% AND country_id = '12' ...

sql add or delete repeat row

I have an output like this: id name date school school1 1 john 11/11/2001 nyu ucla 1 john 11/11/2001 ucla nyu 2 paul 11/11/2011 uft mit 2 paul 11/11/2011 mit uft i will like to achieve this: id name date school school1 1 john 11/11/2001 nyu ucla 2 paul 11/11/2011 mit uft ...