mysql

listing mysql tables starting with a particular letter

hi, I'm new for Mysql how to list all tables in MYSQL DB starting with "T" Tx in adv ...

MySQL server has gone away Error while Selecting rows from a table

Using a C program with Mysql C API connected to a database and the initiation was successful but tried to do SELECT ,INSERT operations it throws an Error " MySQL server has gone away" on my VPS Server but the same works fine locally. The VPS Server Mysql Server version is : 5.0.81-community MySQL Community Edition (GPL) . wait...

what columns to put in MySQL GROUP BY clause

Long story short, what fields should I put after the GROUP BY clause ? SELECT questions.question_id, questions.title, questions.content, questions.view_count, questions.posted_on, users.user_id, users.group_id, users.username, users.first_name, users.last_name COUNT(answers.answer_id) AS answer_count FROM (questions) JOIN answers ON q...

Inserting a python datetime.datetime object into mysql

I have a date column in a mysql table. I want to insert a datetime.datetime() object into this column. What should i be using in the execute statement? I have tried: now = datetime.datetime(2009,5,5) cursor.execute("INSERT INTO table (name, id, datecolumn) VALUES (%s, %s , %s)",("name", 4,now)) I am getting an error as: "TypeError: n...

MySQL method to maintain sequentially numbered "top n" list

CREATE TABLE item ( link MEDIUMINT UNSIGNED PRIMARY KEY NOT NULL, title TEXT NOT NULL, rank INT UNSIGNED NOT NULL AUTO_INCREMENT, notes TEXT ) ENGINE = INNODB; I'm having trouble implementing this. rank is a user given ranking that can be changed at any time, and items can be added and removed ...

GROUP BY for continuous rows in SQL

Given the following table: ID State Date 12 1 2009-07-16 10:00 45 2 2009-07-16 13:00 67 2 2009-07-16 14:40 77 1 2009-07-16 15:00 89 1 2009-07-16 15:30 99 1 2009-07-16 16:00 Question:How can i GROUP by the field "State", while still maintaining the borders between the state changes? SELECT...

is it required to give path after installation MySQL db for Python 2.6

I am using Python 2.6.1, MySQL4.0 in Windows platform and I have successfully installed MySQLdb. Do we need to set any path for my python code and MySQLdb to successful run my application? Without any setting paths (in my code I am importing MySQLdb) I am getting No module named MySQLdb error is coming and I am not able to move further....

Installing mysql on leopard: "Can't connect to local MySQL server through socket"

I migrated to a new machine and used migration assistant to copy across my files (which seemed to copy across the DBs) but I had to use macports to install Mysql (whereas last time I compiled from source via Dan Benjamin's guide). For some reason, mysql is intermittently throwing the following error; Can't connect to local MySQL server ...

MySQL 1 millon row query speed

Hi, I'm having trouble getting a decent query time out of a large MySQL table, currently its taking over 20 seconds. The problem lies in the GROUP BY as MySQL needs to run a filesort but I don't see how I can get around this QUERY: SELECT play_date, COUNT(DISTINCT(email)) AS count FROM log WHERE type = 'play' AND play_date BETWEEN ...

Looking for some clever sql strategies for dealing with a lookup table

I want to store the distance between different locations in a table. CREATE TABLE `example` ( `id` INT NOT NULL AUTO_INCREMENT , `from` VARCHAR( 8 ) NOT NULL , `to` VARCHAR( 8 ) NOT NULL , `distance` DECIMAL( 6, 2 ) NOT NULL , PRIMARY KEY ( `id` ) , INDEX ( `from` , `to` ) ) As a distance between two points is...

I need to start using Versioning and Source Control...

I'm a PHP/MySQL developer who hasn't used any form of versioning aside from copy/paste into a backup folder. I develop Windows, as well. Where should I go, and what should I do to start using Versioning and Control software? I'm curious, do these methods also apply to the databases you're using and their schema's? ...

Getting an error in this Query

function saveFile($catId,$docuTitle,$linkTitle) { $result = mysql_query("INSERT INTO categories (cd_title, cd_link) VALUES ('$docuTitle','$linkTitle') WHERE c_name = '$catID'"); return 'yes'; } I want to insert the cd title and cd links based on the catergory selected. ...

how to insert an empty value in mysql date type field?

How to insert a NULL or empty value in a mysql date type field (NULL = yes). If I try to insert an empty value it inserts 0000-00-00 but I want to keep it empty or NULL. Thanks for help. UPDATE Please see that I have set default value as NULL `payment_due_on` date DEFAULT NULL, Ok OKies I have got it working now function get_m...

Is INNODB enabled by default in MySQL?

I am developing a web app for which I plan to use InnoDB. However I read that sometimes InnoDB is not enabled by default and, one needs to change mysql config to enable it... Is that true? Since my web app will be installed by client themselves on their own web space, I need to make sure my app is as compatible as possible. If InnoDB is ...

Error in SQL UPDATE query

$result = mysql_query("UPDATE categories SET cd_title='$docuTitle' , cd_link='$linkTitle' WHERE c_name='$catID'"); What is wrong with this update query? ...

PHP Sessions stored in MySQL in Ajax heavy environment

I'm looking to change my application to store PHP Session data in MySQL. The application is ajax intensive but does not utilize long-polling or any other type of persistent connection. My question is, are there any gotcha's I need to be aware of when writing this code? For example; I have a page that sends 4 ajax requests to load da...

Storing Image Locations with MySQL and PHP

How to store image location In MySQL? ...

Multi column distinct in mysql

| one | two | ------------- | A | 1 | | A | 2 | | B | 1 | | B | 3 | | C | 1 | | C | 4 | I would like to get no repeats in any column in a query, so the standard SELECT DISTINCT one,two FROM table; or SELECT * FROM table GROUP BY one,two; doesn't quite work, because it looks for distinct in all rows, which in th...

Insert and Update at same time.

$result = mysql_query("INSERT INTO categories (cd_title , cd_link ) VALUES ('$docuTitle','$linkTitle')"); This works fine, but i want to update these values in another field in same table. Once these two are successful i need to pass return values. $result = mysql_query("UPDATE into categories WHERE c_name = '$...

Design problem: fetching more data for some of the records I retrieve in an sql query.

Say I have a query that fetches [type][show_name]. For all [type]==5 records, I need to join them with another table. What would be the best approach for that: Join for all records between the two tables (looks bad). Run the query and then run again on the result set, fetch all the IDs and do a IN query on the table I need to join...