mysql

Help with mysql str-to-date

I cannot get this to work. I want to use str_to_date to convert a date string. Here is my insert statement. INSERT INTO cars(carno, color, date) VALUES ('1', 'brown', STR_TO_DATE('$date', 'm%/%d/%Y')) Can someone please tell me where I am going wrong? The date in my variable is 12/12/2002 Anyone??? ...

MySQL ignores my index

I'm quite new to setting indexes myself. I'm currently just experimenting with it to discover how it works and in what cases a database will make use of the index. I've got a simple table with 3 columns; an id, a name and a status. I've set an index on the name which is a CHAR(30) column. Against my expectations, MySQL ignores this inde...

Make MySQL table unique

Hay, I created a spider to crawl through a PDF document and log every word in the document into a table in a MySQL database. Obviously words like 'the', 'and', 'or' etc appear in a book many, many times. I'm just wondering what's the quickest method to remove dupe values from a table? ...

Finding Total Log Size of each DataBase in the SQL Server 2005?

Possible Duplicate: How to find out size of the individual databases in the sql server 2005? How can I get the log size of a database in SQL Server 2005 Due to permission problem ,I am unable to use the command DBCC SQLPERF(logspace),I am unable to view the properties of the database. Please provide me the query or Advise. ...

"callback" from PayPal to confirm payment?

I have a very simple online ordering app in Perl. The user fills in a form, and when they submit, my app inserts the info into a mySql database, then redirects them to PayPal to complete the payment. The problem is that the database does not have any information about whether they actually completed the payment. I end up having to man...

Using Now() as a default for MySql DateTime type

How can I setup a MySql schema with a DateTime column such that its value will always be the time of the last insert/update to this row? ...

MySQL Query help

I have three columns with three values that can be set for each column Column_1 | column_2 | column_3 ________ | ________ | ________ COMPLETED| FAILED | PENDING COMPLETED| COMPLETED| COMPLETED FAILED | COMPLETED| COMPLETED COMPLETED| PENDING | COMPLETED COMPLETED| COMPLETED| PENDING COMPLETED| COMPLETED| COMPLETED COMPLETED| COMPLE...

How do I show the schema of a table in a MySQL database?

This is a question I did not find answered in Stack Overflow: How do I show the schema of a table in a MySQL database? The answer is to read about the describe command. ...

Separating SQL, PHP and the view when listing categories and products in Kohana

I want to migrate to Kohana with my small websites and I'm trying to separate the SQL, PHP and the view, but I've some problems with this one. I have to tables. Every category can have multiple products. Categories table id category Products table id category_id product This was my previous code (converted to Kohana's query bui...

MySQL count() problem

Setup: create table main(id integer unsigned); create table test1(id integer unsigned); create table test2(id integer unsigned); insert into main(id) value(1); insert into test1(id) value(1); insert into test1(id) value(1); insert into test2(id) value(1); insert into test2(id) value(1); insert into test2(id) value(1); Using: ...

How to get a rough estimate of LAMP application capacity?

I have a LAMP application running fine, however the number of users are increasing each day. I don't want to be hit with a surprise one morning and find that everything broke because of overload. Is there a way to get a rough estimate of what capacity of the LAMP it is at? I know that a full detailed report is many books worth of study...

How to set up a ColdFusion MySQL datasource over SSL?

Is there a way to set up a ColdFusion data source to connect to a MySQL server over a secure connection using SSL? I don't see any obvious option to enable a SSL connection on the data source in CF administrator. The only option I can think of is to use the "connection string" field. This is for a current configuration that is set up....

MySQL query problem

setup: mysql> create table main(id integer unsigned); mysql> create table test1(id integer unsigned,body text); Query OK, 0 rows affected (0.84 sec) mysql> insert into main(id) value(1); Query OK, 1 row affected (0.16 sec) mysql> insert into test1(id,body) value(1,'something1'); Query OK, 1 row affected (0.27 sec) mysql> insert into...

Over Simple Database Schema: Good and Bad points? with example

I apologise for the long-winded, rantyness of this but I'm up at 3am dreading having to go to work tomorrow and deal with this database... it just feels wrong but maybe I'm wrong and just like things done my way... Please tell me what you think. Our database schema looks something like: page: id, label, contentid, parentpageid content...

truncate all tables (most of which have constraints). How to temoprarily drop them

I have a development database (MYSQL) which I would like to load with fresh data at some point. I would like to delete the content of all tables. What is the best way, as automated as possible, to delete the content of all tables (including those that have foreign key constraints). Is there a truncate all/ drop all equivalent constraint...

With multiple Python installs, how does MacPorts know which one to install MySQLdb for?

I just upgraded the default Python 2.5 on Leopard to 2.6 via the installer on www.python.org. Upon doing so, the MySQLdb I had installed was no longer found. So I tried reinstalling it via port install py-mysql, and it succeeded, but MySQLdb was still not importable. So then I tried to python install python26 with python_select python26 ...

How can I synchronize two MySQL tables that have different structures?

I am migrating from one system to another and in the process, I will be running both systems concurrently. I need to be able to synchronize uni-directionally from one table to another while maintaining each table's primary keys. In this example, I have two tables (A) and (B). I need to synchronize value1 and value2 (below) from table B ...

SQL Query to Find Largest "Drawdown" in Table of Financial Transactions

I have a table with the following columns: id int(10) winner int(10) profit double created datetime I'm trying to create a query that returns the largest drawdown, or "peak to trough decline" in terms of the profit column. (More info on drawdown here.) Ideally it would return the value for created for the beginning and end of the dra...

MySQL return new sequential order number in format MMDDYY-#

I've got the following query to generate new order numbers in the format MMDDYY-# where the number is the next in the sequence for today's orders. select concat(date_format(now(),'%m%d%y'),'-',ifNULL(max(right(po_number, LENGTH(po_number)-7)),0)+1) newPO from orders where left(po_number, 6) = date_format(now(),'%m%d%y') This works fi...

Performance benefit in this data model ?

I have a MySQL(innodb) table 'items' with the following characteristics Large number of rows, and keeps on increasing. Large number of columns of various data-types including 'text'; primary key 'item_id' is present. There are additional requirements as follows: Need to query items based on their status Need to update status...