Drupal 7: Database query file

In page.tpl.php of Drupal, the following code has variable $page which contains the html codes that are required to render part of the webpage. <?php if ($page['content']): ?> I'm trying to retrieve the updated content from DB at an interval and upd

MySQL search corresponding to several keywords

Looking for posts matching two keywords (both, not just one of them). I guess the reason why the following MySQL query returns no matches is that keywords matching "climate" and keywords matching "recycling" are not the same rows in th

Only the first item appears in Fill list from asynchronous task

Hello i am trying to build a listview and populate it from values in Mysql database. The list with SimpleAdapter works but i decided to change the listview and use my own adapter that extends ArrayAdapter and create my own listItem and not the HashMa

Mysql multi-line queries

I'm new to MySQL and I am facing a little problem that I couldn't find an answer to in any previous thread here, so I was hoping someone could help, okay here it is: When typing a request on mysql (on the terminal) you can just press enter to make it

Paging problem when sorting based on the last modified property

I need to show some records sorted based on modified column (latest activity on top) (Post with new edit or comments at the top) App UI has twitter like 'more' post button for infinite scroll. each 'more' will add next 10 records to UI. Issue is that

MySQL: Produce a list of people who have more than one object

Say I have a table of people... person: ----------- id | person ---+------- 1 | Jim 2 | Bob 3 | Frank ...and I have a table of items... item: ---------------- id | item | type ---+------+----- 1 | 21 | 2 2 | 10 | 5 3 | 11 | 1 4 | 9 | 1 ...and I also

How to optimize when Mysql uses count (distinct) and attached

I have two table,their structure are below : CREATE TABLE `metaservice`.`user` ( `id` bigint(18) NOT NULL AUTO_INCREMENT, `userId` bigint(18) NOT NULL, `name` varchar(40) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `userId` (`userId`) USING BTREE, K

MySQL parent details if it is a child account

I have a table with data like the following id name created parent ------------------------------------------------ 1 Alpha 11385209583 0 2 Bravo 11385209619 0 3 Bravo-A 11385209701 2 4 Bravo-B 11385209777 2 such that Bravo-A and Bravo-B are children

Python-mysql: When to explicitly cancel a transaction

Suppose, I have a modifying statement: cursor = conn.cursor() # some code affected_rows1 = cursor.execute(update_statement1, params1) # some code conn.commit() cursor.close() Should I wrap the block of code with a try ... except and explicitly rollba

PHP: Duplicate entry 'xx' for key 'yy'

I get the following error: Duplicate entry 'morandi-midnight-train' for key 'post_name' I want to check if post_name field has already a row defined with a variable and echo an error if it does. How can i acomplish this? post_name has a unique indexR

Calculation of short distances between lat / long points

I have a MySQL table with Spatial Points, and need to calculate distances. I found lots of material on doing this using the Haversine formula, however all of these assume a large distance between points. In my case, I only care about short distances

Multiple INSERT does not work

I have multiple If statements that if true, inserts data into the db. The Problem is that the 2nd one of the INSERT statements inserts it 4 times. How would i stop it from adding duplicates. Also the returned $_POST['tshirt'] contains only one value

MySQL Street Address Blurred Search

Does anyone know of a good script (or good strategy) for doing a fuzzy street address search on a MySQL database? The key issues are: capitalization (easy -- just use LCASE) punctuation (could use REPLACE; not sure it there are more efficient options

Return of the first result where CASE result = X?

I'm trying to return to write a query that only returns first result where someid (result of the first case)=X - and ignoring subsequent results where someid=X. How would I alter the following query to achieve that? Here's what I'm currently using: S

Mysql string contained in a search string

What I need seems simple, but I haven't been able to pull it off so far. Maybe it's just these late hours, or maybe it's not that simple after all, I don't know any more :) So, here's the thing. I want to be able to check whether the search string fr


I have one table ( members ) and five columns ( username , password , FirstName , LastName , Email ) I need to get the Email for the user admin. How would this be done? SELECT Email FROM members WHERE username = 'admin';