mysql

how to implement a sorting subquery in the 'from' section?

I need to have a subquery order a table before joining so that when I group the table, the proper collapsed data is shown. For the example query, I want the latest start time before a given datetime (2006-08-26 00:00:00) select * from parts p left join (select * from transactions t left join transactiondetails td on(td.transaction_...

optimizing query

I have a Table foo which records the sightings of bird species. foo_id is its PK, other concerned columns are s_date, latitude and longitude. species_id is its FK. I have indexes on s_date, latitude and longitude, species_id. Table foo has 20 million records and increasing. The following query gives me top 10 latest species sightings in ...

Selecting a Python Web Framework

Hello everybody. This may seem like a subjective question. But it is not (that's not the idea, at least). I'm developing an Advertising software (like AdWords, AdBrite, etc) and i've decide to use Python. And would like to use one of those well known web frameworks (Django, Cherrypy, pylons, etc). The question is: Given that it will ...

Problem using mysql++ library

I've read the tutorial at, and I generally get how that works: http://tangentsoft.net/mysql++/doc/html/userman/tutorial.html#simple I am trying to build this mysql++ code, and I'm getting an error: std::ostringstream query3; query3<<"select pipe_id from pipe where version_id='"<<id<<"'"; std::storeQueryResult ares=query3.store(); for(...

I was trying to select rows using mysql++

Here is my code int main(int argc,char *argv[]) { mysql_init(&mysql); connection = mysql_real_connect(&mysql,.............,"3306",0); if (connection == NULL) { cout << mysql_error(&mysql); return 1; } else { int id=1; mysqlpp::Query query=connection.query("select * from pipe"); //query3<<"select pipe_id from pipe w...

Cannot create PoolableConnectionFactory (Access denied for user ''@'localhost'

Hi there, I have been trying to set up a DatabaseConnectionPool for a web app for the last couple of days with no success. I have read the relevant sections of the Tomcat docs and a great deal around the subject and think I'm doing everything right, but obviously not because I keep on getting the following error: Cannot create Poolable...

show duplicate records

I have this query SELECT id, timeOrdered, order_desc, firstname, lastname FROM `db`.`myTable` WHERE `myTable`.`customer_number` IN (100, 101, 102, 103, 104, 105) I am trying to find which are duplicate records. If the timeOrdered, order_desc, firstname, lastname are same then its dupe. What would be the query for that Thanks ...

What's the best way to escape user input for Regular Expressions in MySQL?

I'd like to take user input, denoted as $dangerous_string, and use it as part of a RegEx in a MySQL query. What's the best way to go about doing this? I want to use the user's string as a literal -- if it contains any characters that mean something in MySQL RegEx, those characters should not actually affect my Regular Expression. $dan...

Apache/MYSQL Problem

Basically, I get this error in my scripts: Fatal error: Call to undefined function mysql_connect() in /var/www/login/includes/db.php on line 10 I have uncommented extension:mysql.so I dont know why its not working, restarted everything aswell. I am running on ubuntu 32 bit. Apache/MYSQL is installed with full permissions. Here is m...

Is there a MySql binary dump format? Or anything better than plain text INSERT statement?

Is there anything better (faster or smaller) than pages of plain text CREATE TABLE and INSERT statements for dumping MySql databases? It seems awfully inefficient for large amounts of data. I realise that the underlying database files can be copied, but I assume they will only work in the same version of MySql that they come from. Is t...

Unicode characters are being saved incorrectly.

I have a mysql database with unicode text strings in it. My JSF application (running on tomcat 6) can read these unicode strings out and display them correctly in the browser. All the html charsets are set to UTF-8. When I save my object, even having made no changes, Hibernate persists it back to the database. If I look directly in the ...

how can i change the pattern in php?

i got this pattern for searching purpose for mysql from third party javascript. im assuming its html pattern, which can be converted, anyone have any idea on this? pattern A%5B%D9%8B-%D9%93%D9%B0%5D*L%5B%D9%8B-%D9%93%D9%B0%5D*L%5B%D9%8B-%D9%93%D9%B0%5D* ...

Updating a table joining another table

Hi, Update a table joining 1 more table. UPDATE t1 SET t1.col1 =1 FROM table1 t1 JOIN table2 t2 ON t1.ID=t2.ID WHERE t1.Name='Test' AND t2.Age=25; i get this error,You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM table1 t1 JOIN table2 t2 .....

Help with querying a many to many table in mysql

I am trying to get a list of product id's that do not have certain colors (database is mysql) Here are my tables: product +------------+-------------+ | product_id | description | +------------+-------------+ | 1 | Widget 1 | | 2 | Widget 2 | | 3 | Widget 3 | | 4 | Widget 4 | | 5...

CakePHP Queries involving DateTime

I'm having some trouble working out how to do comparisons on a datetime field, in the course of a CakePHP query. I want for instance to be able to periodically delete all records from my database that relate to an event that occurred in the past. But I haven't gotten much further than: $this->Item->deleteAll( 'conditions'=>array('da...

Black Diamonds that are Fixing themselves in MySQL

I am running into a very strange issue with a site that I am working on. The site is basically a job board where the owner or users can create job listings including a description that ends up being stored into a MySQL text field. What we are experiencing is this, whenever listings from certain sources are entered, they initially end up ...

Get Upcoming Birthdays Mysql and PHP

I've been trying to get upcoming birthdays using mysql statement and php. Problem is i've seen some solutions but they use date fields. Unfortunately mine is stored as timestamps. The code below only yields results if the birthdate is after 1970. How can I get a query that will give me current month, next month, month after and so on of ...

MySQL's MD5 hash is incorrect

PHP's md5("123123") gives me a correct value of 4297f44b13955235245b2497399d7a93, while mysql's select md5("123123"); gives me '6e9abeea535938c496a261b3b39c0d79'. Why would this happen ? does this have anything to do with mysql server incoding? I kinda lost it, help much appreciated! Thank you! ...

Create custom rollback

So I am going through our database and removing some unneeded access levels that are basically duplicates of other ones. Our database structure has a column user_level which is an enum that has a bunch of different strings (I know this isn't a great way to run user access levels but this is how the original developer made it). What I am...

Multiple Databases with Zend

Hey there, I'm building an application (using the zend framework) where we will have multiple clients who login and use the application, and each of these clients will be storing lots of data about their users (I'm using MySQL btw). Basically I'm wondering 2 things: Is having multiple databases, one for each client (ie. ipd_client_CL...