mysql

How to change bdb cache size in mysql?

I would like to change variable bdb cache size (bdb_cache_size) on my mysql database to be able to import bigger SQL files (yes, i've set all other variables for example in php.ini to higher values and it does not work) in phpmyadmin. How can I do that? ...

Codeigniter: How to do a select (distinct fieldname) MySQL query

I'm trying to retrieve a count of all unique values in a field. Example SQL: SELECT count(distinct accessid) FROM (`accesslog`) WHERE record = '123' How can I do this kind of query in CodeIgniter? I know I can use $this->db->query() and write my own SQL, but I have other requirements that I want to use $this->db->where() for, and if...

What is the best method/options for expiring records within a database?

In a lot of databases I seem to be working on these days I can't just delete a record for any number of reasons, including so later on they can be displayed later (say a product that no longer exists) or just keeping a history of what was. So my question is how best to expire the record. I have often added a date_expired column which i...

Using DELAY_KEY_WRITE in MySQL: Should I use it? Is there anything else I need to change?

I have a logging table that stores the user id, date/time, table name, record id, query type (insert, update, delete, etc), and the full SQL that was run. There are a couple keys on this table, but they don't need to be updated right away. Typically the table is used to eitehr check for problems (someone made a mistake or there was a sys...

Find the number of columns in a table

Hi friends, It's possible to find the number of rows in a table: select count(*) from tablename Is it possible to find the number of columns in a table? Thanks in Advance. Praveen J ...

Drawback to having cache enabled, but sized to 0 in MySQL?

Is there a performance hit, or any other drawbacks to leaving query caching enabled in MySQL 5, but sizing the cache to 0 bytes? I assume that any performance impact would be minimal if any, but I'm wondering if there are any other issues which might arise that I have not considered. ...

How can I generate a round robin tournament in PHP and MySQL?

I need to generate sequences of games using the round robin algorithm. I have the php page where the user can input the tournament name which will be inserted into the database and it has got a drop down menu up to 32 teams (select number of teams). So if I select 4 teams in the page, so it will be from team 1 to team 4 which would be ...

pinging mysql using mysql alchemy and python

how do i ping mysql using mysql alchemy and python? ...

Cache/Re-Use a Subquery in MySQL

I have a very complex MySQL query that includes use of the same subquery three times. Will MySQL actually run the subquery three times? (It's an expensive one.) If so, is there a way for me to tell MySQL to save or cache the results so it won't do that? I could save the data in a large array then re-feed it to MySQL, but I'd rather not m...

Is there a faster way to backup and restore for mysql?

Sql Server and Oracle have commercial products like Idera (Sql Safe) and Quest (LiteSpeed) that dramatically speed up backup and restores. Does mysql have any commercial software like that? I'm working with large amounts of data in mysql and if we have to restore it takes 8-10 hours. So I'm hoping to move to a commercial product that...

MySQL: Total GROUP BY WITH ROLLUP curiosity

I have two queries. One of them makes sense to me, the other don't. First one: SELECT gender AS 'Gender', count(*) AS '#' FROM registrations GROUP BY gender WITH ROLLUP That gives me this: Gender # Female 20 Male 19 NULL 39 So, I get the count, and the total count. What I expected. Next one: SELEC...

What problems can arise if php mysql client doesn't match the mysql server version?

I have two installations of mysql server 5.1.32 and 5.0.77 (same machine, os x leopard). My php mysql extension is compiled against 5.0.77 (that was the easiest thing to do, and I did it after installing 5.1.32). I'm using the 5.1.32 installation since that's what I compiled my python MySQLdb extension against. I don't code in php much i...

How to delete duplicate records in mysql database?

What's the best way to delete duplicate records in a mysql database using rails or mysql queries? ...

MySQL: Retrieve Unique Values and Counts For Each

Is there a simple way to retrieve a list of all unique values in a column, along with how many times that value appeared? Example dataset: A A A B B C ... Would return: A | 3 B | 2 C | 1 Thanks! ...

Looking for a PHP query designer framework

I have a client that wants to move their users from MS-Access to a PHP/MySQL web application. The data has already been migrated to MySQL and, thankfully, there are no Access forms, just queries. What they want me to do is build some kind of querying framework where users can build queries, save them, filter/drill-down results, sort by...

How do you assign a column default in MySQL to another column's value?

I want to add a new column to a table in MySQL database that should get the value of another column in the same table. Is this possible? If so, how do you do it? Thanks! ...

mysql dump outside the command line

Do any of the modern programming languages support mysqldump as a method, Or is it still the domain of command line environments. ...

What are the differences between MySQL hosted on Windows and Debian (Linux)?

Hi All, I'm in the process of migrating a MySQL database from Debian to windows vista (localhost using Apache - installed and running via EasyPHP). The database is essentially a carbon copy, every entry is the same, however when I try to access the database, I get some strange errors (for example, in some cases the first few entries in...

How can I merge two mysql databases with identical schema?

I need to merge two two mysql databases with identical schema. I am looking for some tool that can read database meta-data (PK, FK) and automatically generate new PKs, updating all the FKs automatically. ...

How to sum an attribute in a sphinx group search?

I need sphinx to sort the results by the sum of an attribute. I need to: Group the results by their IDs (done) Sort the results by the SUM of one attribute I can't find a way to sum this attribute. How could I do this? (Im using sphinx PHP API) ...