mysql

Caching MySQL queries

Is there a simple way to cache MySQL queries in PHP or failing that, is there a small class set that someone has written and made available that will do it? I can cache a whole page but that won't work as some data changes but some does not, I want to cache the part that does not. ...

Swapping column values in MySQL

I have a MySQL table with coordinates, the column names are X and Y. Now I want to swap the column values in this table, so that X becomes Y and Y becomes X. The most apparent solution would be renaming the columns, but I don't want to make structure changes since I don't necessarily have permissions to do that. Is this possible to do w...

concatenate several fields into one with SQL

i have three tables tag, page, pagetag With the next data page ID NAME 1 page 1 2 page 2 3 page 3 4 page 4 tag ID NAME 1 tag 1 2 tag 2 3 tag 3 4 tag 4 pagetag ID PAGEID TAGID 1 2 1 2 2 3 3 3 4 4 1 1 5 1 2 6 1 3 I would like to get a str...

How do you manage SQL Queries

At the moment my code (PHP) has too many SQL queries in it. eg... // not a real example, but you get the idea... $results = $db->GetResults("SELECT * FROM sometable WHERE iUser=$userid"); if ($results) { // Do something } I am looking into using stored procedures to reduce this and make things a little more robust, but I have some...

Selecting X words from a text field in MySQL

I'm building a basic search functionality, using LIKE (I'd be using fulltext but can't at the moment) and I'm wondering if MySQL can, on searching for a keyword (e.g. WHERE field LIKE '%word%') return 20 words either side of the keyword, as well? ...

Asynchronous Mysql connector for C++ or C

Does there exist any asynchronous connectors to Mysql that can be used in C or C++? I'm looking for something that can be plugged into a reactor pattern written in Boost.Asio. [Edit:] Running a synchronous connector in threads is not an option. ...

Generate field in MySQL SELECT

If I've got a table containing Field1 and Field2 can I generate a new field in the select statement? For example, a normal query would be: SELECT Field1, Field2 FROM Table And I want to also create Field3 and have that returned in the resultset... something along the lines of this would be ideal: SELECT Field1, Field2, Field3 = 'Valu...

group_concat query performance

i am having serious performance problems (queries up to 55 seconds) while running a mysql query since i added a group_concat clause. my query looks like: select ... group_concat(distinct category.name) .... from page where left outer join page_category on page.id = page_category.page_id left outer join category on page_category.cat...

How to download a live MySQL db into a local test db on demand, without SSH?

I have a fairly small MySQL database (a Textpattern install) on a server that I do not have SSH access to (I have FTP access only). I need to regularly download the live database to my local dev server on demand; i.e., I would like to either run a script and/or have a cron job running. What are some good ways of doing this? Some points ...

Searching for phone numbers in mysql

I have a table which is full of arbitrarily formatted phone numbers, like this 027 123 5644 021 393-5593 (07) 123 456 042123456 I need to search for a phone number in a similarly arbitrary format ( e.g. 07123456 should find the entry (07) 123 456 The way I'd do this in a normal programming language is to strip all the non-digit chara...

Looking for MySQL IDE?

I've recently been tasked with developing a web application that will use a MySQL database on the back end. I for most of my career I have worked with MS-SQL Manager. My greatest weakness is in defining foreign key constraints I usually use MS-SQL Manager's diagramming tool to draw my relationship lines between tables. ...

How do I install the mysql ruby gem under OS X 10.5.4

Here is the deal. $ gem --version 1.1.0 $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Bulk updating Gem source index for: http://gems.rubyforge.org/ ERROR: could not find mysql locally or in a repository $ sudo gem update Updating installed gems Bulk updating Gem source index...

How do I execute PHP that is stored in a MySQL database?

I'm trying to write a page that calls PHP that's stored in a MySQL database. The page that is stored in the MySQL database contains PHP (and HTML) code which I want to run on page load. How could I go about doing this? ...

Import OLE Object from Access to MySQL

I have a table in an access table which contains Product entries, one of the columns has a jpg image stored as an OLE Object. I am trying to import this table to MySQL but nothing seems to work. I have tried the MySQL migration tool but that has a known issue with Access and OLE Objects. (The issue being it doesnt work and leaves the...

Using MySQL on Visual Studio 2008

I am using the ODBC connector to access a MySQL db from visual studio 2008 and i am facing performance problems when dealing with crystal reports and to solve this i need a native connector to visual studio. if someone has had a similar problem and knows a solution or tools ( freeware preferable ) , i would be really grateful. ...

SQL Number Formating

I'm looking to use SQL to format a number with commas in the thousands, but no decimal (so can't use Money) - any suggestions? I'm using SQL Server 2005, but feel free to answer for others as well (like MySQL) ...

How can I use Linq with a MySql database on Mono?

There are numerous libraries providing Linq capabilities to C# code interacting with a MySql database. Which one of them is the most stable and usable on Mono? Background (mostly irrelevant): I have a simple C# (.Net 2.0) program updating values in a MySql database. It is executed nightly via a cron job and runs on a Pentium 3 450Mhz, L...

Is there any way to see the progress of an ALTER TABLE statement in MySQL?

For example, I issued an ALTER TABLE statement to create an index on a MEDIUMTEXT field in an InnoDB table that has 134k rows where the size of the index was 255 bytes and the average size of the data in the field is 30k. This command has been running for the last 15 minutes or so (and is the only thing running on the database). Is the...

Can I update/select from a table in one query?

I need to select data when a page is viewed and update the 'views' column is there a way to do this in one query, or do I have to use to distinct queries? ...

Calculated columns in mysql on INSERT statements

Let's say that I want to have a table that logs the date and the number of columns in some other table (or really any sort of math / string concat etc). CREATE TABLE `log` ( `id` INTEGER NOT NULL AUTO_INCREMENT , `date` DATETIME NOT NULL , `count` INTEGER NOT NULL , PRIMARY KEY (`id`) ); Is it possible to have the count column calcula...