mysql

Substitute MySQL result

I'm getting the following data from a MySQL database +----------------+------------+---------------------+----------+ | account_number | total_paid | doc_date | doc_type | +----------------+------------+---------------------+----------+ | 18 | 54.0700 | 2009-10-22 02:37:09 | IN | | ...

How to select multiple tables using mysql?

Okay, so far I can select two tables using mysql but I cant select three or more tables using mysql how can I select more then three tables using mysql. Here is the code below. SELECT users.*, oldusers.* FROM users, oldusers WHERE users.user_id='$user_id' = oldusers.user_id I'm trying to add all the tables contents into something lik...

MySQL: Usage of indices in UNION subselects

In MySQL 5.0.75-0ubuntu10.2 I've got a fixed table layout like that: Table parent with an id Table parent2 with an id Table children1 with a parentId CREATE TABLE `Parent` ( `id` int(11) NOT NULL auto_increment, `name` varchar(200) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB CREATE TABLE `Parent2` ( `id` int(11) NOT NUL...

Counting Instances of Unique Value in Field

Suppose you have a table in SQL: Prices ------ 13.99 14.00 52.00 52.00 52.00 13.99 How would you count the amount of times a DIFFERENT field has been entered in? Therefore an example of such a count would output: 13.99 - 2 times. 14.00 - 1 times. 52.00 - 3 times. OR perhaps: 3 (i.e. 13.99, 14.00, 52.00) Can anyone advise? ...

How many fields should be indexed and how should I create them?

I've got a table in a MySQL database that has the following fields: ID | GENDER | BIRTHYEAR | POSTCODE Users can search the table using any of the fields in any combination (i.e., SELECT * FROM table WHERE GENDER = 'M' AND POSTCODE IN (1000, 2000); or SELECT * FROM table WHERE BIRTHYEAR = 1973;) From the MySQL docs, it uses left inde...

what is wrong with this WHERE clause?

is there a reason why this query wouldn't work? the following query will work if i just exclude the WHERE clause. I need to know what is wrong with it. I know the values of $key given exist in the table so why wouldn't this work? $q = "SELECT * WHERE t1.project=$key FROM project_technologies AS t1 JOIN language...

Count Instances in Table1 AND link to Table2

Please refer to this background question. After constructing this COUNT, how would I then link each of these 'Prices' to, for instance, a column called 'Genre' in TableTwo? e.g. Table1: Prices, ID Table2: Genre, ID Example output: PRICES, COUNT, Genre -------------------- 13.99, 2, Horror 52.00, 3, Comedy 1.99, 1, Rom...

Getting BLToolkit to work with MySQL

Heya, I'm currently trying to get bltoolkit working in my project. I've added the BLToolkit.3 project to my solution and am referencing it appropriately. The code in question is really simple. public List<Account> LoadAccounts() { using (DbManager db = new DbManager("MySql")) { var query = new SqlQue...

How to make MySQL log down all queries that didn't use index?

I'm starting to do the job of sql optimization, but I don't know how to configure MySQL properly to make it log slow queries. ...

How to know which index used by the SELECT in MySQL?

The table has many different indexes, and some indexes share one field. I want to know which index used in a select query. ...

Display all unique ID's even on 'limit' in MYSQL

Hi, I guess this is strange situation. I have a results table which contain 100k records, basically this table consists of transactions with particular ID's ( not PK). I am displaying the results limiting the records to 3000. I am using Javascript tool box to display a filter on top of table heading so that users can select / filter...

Caching table results for better performance... how?

First of all, the website I run is hosted and I don't have access to be able to install anything interesting like memcached. I have several web pages displaying HTML tables. The data for these HTML tables are generated using expensive and complex MySQL queries. I've optimized the queries as far as I can, and put indexes in place to impr...

Linux diff and patch command line utilities for MySQL data (not structure)

I have two MySQL databases and I would like to write a script to compare and update data changes between them. Does anyone know a Linux command line tool for diffing or patching data in MySQL databases? ...

Find a Windows-1252 char in mysql column

There's a row that I believe contains a Windows-1252 smart-quote char in a particular column that is messing up a user of this table. How can I select any row that contains any Windows-1252 punctuation in this column? AND it would be really cool if I had a way of converting these values if I redefine the column as being utf8 (it's curre...

Mark record inserted

I have table, which I am inserting records to another table. What is the best way to mark record inserted, so it will not be attemted to being inserted again? ...

Overkill to add last_modified column to all tables?

When designing database tables for a fresh new project, is it good practice to add a last_modified column, which auto-updates, for every table? Is the performance hit to have auto-updating last_modified columns too much to make it worthwhile? This column could have a number of uses, one being to aid with caching. But is it overkill to ...

WhichdDatabase would prove efficient?

I have to develop a web application in Java, a pretty big one with loads of data to store and manipulate. I am also planning to use Hibernate and Spring. There are many databases available now like MSSQL Server, MySQL Server, Oracle, db2, etc.. Which do you recommend? Features I look for would be Java - database connection should be ...

How to make MySQL read my.cnf again without restarting?

Is there such a command? I've modified my.cnf,and I don't want to stop/start MySQL. ...

Problem with quotes and paramterized SQL query

I have a very simple search form, that takes in a term from GET_, and then incorporates this into an SQL query. I am trying to use this string from GET in a paramterized query, like so: $searchString = '%' . $searchString . '%'; $recordsQuery = "SELECT username, firstname, lastname FROM $table WHERE lastname = $searchString" . $max; ...

How to optimize this query?

Query: select id, title from posts where id in (23,24,60,19,21,32,43,49,9,11,17,34,37,39,46,5 2,55) Explain plan: mysql> explain select id,title from posts where id in (23,24,60,19,21,32,43,49,9,11,17,34,37,39,46,5 2,55); +----+-------------+-------+------+---------------+------+---------+------+------+-------------+ | id...