mysql

MySQL - Combining question answers from multiple transactions

I have the follow tables in a database that I am using to store the results of surveys: http://img19.imageshack.us/img19/5016/strtranans.jpg Each time I speak to someone at a store (read Shop) I create a new transaction, with a date time (tblTransaction.Created). Each transaction can many question answers associated with it. My probl...

Comma separated Values

How can i fetch this query using mysql? Table1: id : nos 1 12,13,14 2 14 3 14,12 Table2: id : values 12 PHP 13 JAVA 14 C++ Now , I want output like this: 1 PHP, JAVA, C++ 2 C++ 3 C++, PHP ...

MySQL: Many tables or many databases?

For a project we having a bunch of data that always have the same structure and is not linked together. There are two approaches to save the data: Creating a new database for every pool (about 15-25 tables) Creating all the tables in one database and differ the pools by table names. Which one is easier and faster to handle for MySQL?...

Best way to regenerate massive MySQL tables

I am working on an app which requires several very large MyISAM tables being rebuilt daily (mainly searching tables which are rebuilt using the latest industry and site data). The queries used to rebuild these tables are extremely heavy and unsuitable for running against the main production database. We have a separate server specifica...

What are the various possibilities to use MySql in a desktop applicaion

Can MySql database be used as a back-end of a desktop application. What are the various possible ways to do it? ...

Nhibernate mapping tool for MySQL

Is there any mapping tool for nhibernate-mysql? I want a mapping tool that Takes in a MySQL database General the relevant hbm.xml file Create the data access layer class that maps to each table. Is there any such tools available? ...

Stored Procedure with optional "WHERE" parameters

Hi to all. I have a form where users can specify various parameters to dig some data (status, date ecc). I can producea query that is: SELECT * FROM table WHERE: status_id = 3 date = other_parameter = etc. Each WHERE is optional (i can select all the rows with status =3, or all the rows with date = 10/10/1980, or all the rows with st...

Best practices for optimizing LAMP sites for speed?

I did a cursory search and couldn't find this question and this could be viewed as a multi-part question so help me out in either case if I made a mistake. I want to know when building a typical site on the LAMP stack how do you optimize it for the best possible load times. I am picturing a typical DB-driven site. This is a high-level...

changing sorting criteria after the first result

I am selecting from a database of news articles, and I'd prefer to do it all in one query if possible. In the results, I need a sorting criteria that applies ONLY to the first result. In my case, the first result must have an image, but the others should be sorted without caring about their image status. Is this something I can do with...

Ordering Wordpress posts by most recent comment

I'm wanting to order Wordpress posts by the most recent comment. To the best of my knowledge this isn't possible using the WP_Query object, and would require a custom $wpdb query, which I can easily write. However, I then don't know how to setup the loop to run off this object. Can anyone help? ...

Fetching a MySQL SET column as a list of integer offsets

I have a table in a MySQL database defined similar to the following: CREATE TABLE doc_types ( id INT UNSIGNED PRIMARY KEY, types SET('foo','bar','baz','quux',...) NOT NULL ) I would like to get the value of the types column as a comma-separated list of 1-based integer offsets into that list of set values, e.g. "1,3,4" for a...

Transferring MySQL Database Link Across Multiple PHP Pages

Are there any tricks to transferring and/or sharing the Resource Links across multiple PHP pages? I do not want the server to continue connecting to the database just to obtain another link to the same user in the same database. Remember that the link returned from mysql_connect() is automatically closed after the script it originated o...

InnoDb working some of the time but not others

I'm in the process of swapping over a database for a rewrite of my program and part of that is writing both a conversion script and a script to create new tables. I'm renaming tables, changing indexes and generally altering most of the table in some way, part of that is that I'm changing from MyISAM to InnoDB tables. The conversion scr...

How can I access the MySQL command line with XAMPP for Windows?

How can I access the MySQL command line with XAMPP for Windows? ...

What query will work for this sub-type / super-type relationship?

Here is the situation. I have 3 tables, one super type, and two sub types, with a relationship between the sub types: |----------------| |-------------------| |-------------------| | Post | | Top_Level | | Comment | |----------------| |-------------------| |-------------------| | PK | ID | ...

Querying similar but disjoint datasets in a single SQL query

In SQL (specifically MySQL, but the question is generic enough), what is the most efficient way to query time-series data when I have multiple tables across disjoint time ranges? For example, if my tables are as follows: router1_20090330( unixtime integer unsigned, iface1_in integer unsigned, iface1_...

RegEx to insert a string before each table in a MySQL query

I need to take a MySQL query and insert a string before each table name. The solution doesn't need to be one line but obviously it's a regex problem. It will be implemented in PHP so having programming logic is also fine. Rationale and Background: I'm revamping my code base to allow for table prefixes (eg: 'nx_users' instead of 'users'...

Transactions in wordpress database

Wordpress is using MyISAM storage engine. MyISAM does not support transactions. How wordpress is maintaining transactions? I mean if wordpress is having two database write operations, how does it ensure atomicity? ...

MySQL LEFT JOIN after 5.0.12 changes - How to rewrite query

After 5.0.12 MySQL changed the syntax for left joins to match SQL2003 standard. So ... FROM t1 , t2 LEFT JOIN t3 ON (expr) needs to be rewritten as ... FROM (t1 , t2) LEFT JOIN t3 ON (expr or else it will be parsed as ... FROM t1 , (t2 LEFT JOIN t3 ON (expr)) Now, I have an ancient app I'm porting from MySQL 3.23 (eek!) to 5.1, a...

variable database name

Is there any way in MySQL to put the name of the database into a variable? For example, when I have a database called 'db1', can I do something like this: set @db= 'db1'; select * from @db.mytable; EDIT: There is another example of what I want to do: set @dbfrom= 'db1'; set @dbto= 'db2'; insert into @dbto.mytable (col1,col2,col3) sel...