mysql

Install MySQLdb (for python) as non-compressed egg

The install instructions are: $ python setup.py build $ sudo python setup.py install # or su first This gives me an .egg file. How do I tell the install to dump the files as a normal, uncompressed library? Thanks! ...

MySQL Cross-Table Count(*) Query Help

SELECT `name` , COUNT(*) AS `count` FROM `t1`, `t2` WHERE `t2`.`id` = `t1`.`id` GROUP BY `t2`.`id` I want to obtain the name from t1 and the number of rows in t2 where the id is the same as on t1. I've got the above so far, however it won't return any data if there are no rows in t2 that match. I'd prefer count to be 0 (or NULL) if t...

have mysql select statement return fully qualified column names like table.field

is there a way to have a mysql select statement return fully qualified column names like "table.field" without using AS for every single field? like so: SELECT * FROM table1 LEFT JOIN table2 on table1.f_ID = table2.ID and the result would be: "table1.ID", "table1.name", "table2.ID", "table2.name", ... ...

MySQL Character sets

If I need a varchar(30) field, for example, that needs to contain several different foreign character sets, is there one particular language type that I can use in MySQL? For example, I have a field contains names in Chinese, Russian, English, Spanish and Portuguese, and possibly more in the future. How do I enable this for a varchar()...

converting access datetime type to mysql type

Hello, I am trying to convert an access datetime field to a mysdl format, using the following string: select str_to_date('04/03/1974 12:21:22', '%Y %m %d %T'); While I do not get an error, I do not get the expected result, instead I get this: +---------------------------------------------------+ | str_to_date('04/03/1974 12:21:22', ...

How to Fix This MySQL Query So It Works?

I have the following query: UPDATE lessonstatus INNER JOIN user ON lessonstatus.user_id = user.user_id SET user_id = (SELECT user_id FROM user WHERE username = 'too_many_accounts') WHERE last_name = 'stupid' AND first_name = 'user' AND username != 'too_many_accounts' AND lessonstatus.lesson_id NOT IN (SELECT lesson_id FROM lessonstatus...

Autocomplete in MySQL under Windows

Does anybody know if there is a way to make autocompletion work in MySQL Command Line Client under Windows? It's working nicely under Linux for me, but simply moves the cursor under Windows instead. ...

How can I Cause a Deadlock in MySQL for Testing Purposes

I want to make my Python library working with MySQLdb be able to detect deadlocks and try again. I believe I've coded a good solution, and now I want to test it. Any ideas for the simplest queries I could run using MySQLdb to create a deadlock condition would be? system info: MySQL 5.0.19 Client 5.1.11 Windows XP Python 2.4 / MySQ...

How to count open db connections ?

I'm developing a web app using Java servlet to access Mysql db, how can I get the number of connections to my DB that is currently open ? Edit : I tried "show processlist", it showed me : 2695159, but that's not right, I'm just developing this new project, I'm the only user, couldn't have that many processes running, what I want is the...

Can I use a function for a default value in MySql?

I want to do something like this: create table app_users ( app_user_id smallint(6) not null auto_increment primary key, api_key char(36) not null default uuid() ); However this results in a error, is there a way to call a function for a default value in mysql? thanks. ...

How to Write a Query to Merge Two Accounts and their Activity Logs into One?

We frequently have users that create multiple accounts and then end up storing the same lesson activity data more than once. Once they realize the error, then they contact us to merge the accounts into a single one that they can use. I've been beating myself to death trying to figure out how to write a query in MySQL that will merge th...

Why does Hibernate/JDBC/MySQL drop connections after a day or so?

I have several server processes that once in a while respond to messages from the clients and perform read-only transactions. After about a few days that the servers are running, they stop working correctly and when I check it turns out that there's a whole bunch of messages about the connection being closed. When I checked it out, it ...

MySQL C API using results

I am using the "MySQL C API" to query the database and I have the results stored in MYSQL_ROW types. I am able to use print the results to the console with printf("%s", row[0]), however, according to the MySQL C API documentation, I cannot use them as null-terminated strings. At the bottom of http://dev.mysql.com/doc/refman/5.0/en/c-ap...

search question

I'm working on a search module that searches in text columns that contains html code. The queries are constructed like: WHERE htmlcolumn LIKE '% searchterm %'; Default the modules searches with spaces at both end of the searchterms, with wildcards at the beginning and/or the end of the searchterms these spaces are removed (*searchterm -...

How to select maximum 3 items per users in MySQL?

Hi, I run a website where users can post items (e.g. pictures). The items are stored in a MySQL database. I want to query for the last ten posted items BUT with the constraint of a maximum of 3 items can come from any single user. What is the best way of doing it? My preferred solution is a constraint that is put on the SQL query re...

Regular expression for searchterms not preceded or followed by [a-z] and [A-Z]

Can someone supply me with the regexp for searching for a searchterm that is not preceded or followed by [a-z] and [A-Z], other characters are ok. -> i.e. when searching for 'key' i don't want keyboard in my searchresults but key. is okay. Thanks! ...

Best way to connect to MySQL locally?

MySQL offers many ways (on Windows) to connect to it, those are: Shared memory Named pipes TCP/IP My question is, if MySQL will be run on the same machine of the web server, then which method is best for security and performance? P.S. This is a one web server scenario, no web farm. Thanks ...

How do I delete all the records in a table that have corresponding records in another table

I have two tables A and B. I would like to delete all the records from table A that are returned in the following query: SELECT A.* FROM A , B WHERE A.id = B.a_id AND b.date < '2008-10-10' I have tried: DELETE A WHERE id in ( SELECT a_id FROM B WHERE date < '2008-10-10') but that only works if the inner select ac...

inserting into mysql

Hello, I have the following database table created thus: CREATE TABLE AUCTIONS ( ARTICLE_NO VARCHAR(20), ARTICLE_NAME VARCHAR(100), SUBTITLE VARCHAR(20), CURRENT_BID DECIMAL(5,2), START_PRICE DECIMAL(5,2), BID_COUNT VARCHAR(20), QUANT_TOTAL VARCHAR(20), QUANT_SOLD VARCHAR(20), ACC...

Binlog MySQL Replication is a "Bag of Hurt". Are there any good alternatives?

I've honestly tried this left and right and still find that my mirror server, set up as a replication slave still lags behind. My app's user base keeps growing and now Ive reached the point where I can't keep "shutting down" to "resync" databases (not even on weekends). Anyways, my question: Are there any plausible, affordable, alternat...