mysql

why won't it post these results?

I am having trouble grabbing the values from the form once processed. I need your help. function updateUser($table, $id) { if($_POST) { processUpdate($table, $id); } else { updateForm($table, $id); } } function processUpdate($table, $id) { print $table; //testing print $id; //testing $email=addslashe...

Database backup of a mysql database in VB.Net.

How do you create a database backup of a mysql database in VB.Net? ...

In mysql, can you divide one alias, by another?

I have a multi-table query, similar to this (simplified version) SELECT columns, count(table2.rev_id) As rev_count, sum(table2.rev_rating) As sum_rev_rating FROM table1 LEFT JOIN table2 ON table1.dom_id = table2.rev_domain_from WHERE dom_lastreview != 0 AND rev_status = 1 GROUP BY dom_url ORDER BY sum_rev_rating/rev_count DESC The...

MySQL: Select N rows, but with only unique values in one column

Given this data set: ID Name City Birthyear 1 Egon Spengler New York 1957 2 Mac Taylor New York 1955 3 Sarah Connor Los Angeles 1959 4 Jean-Luc Picard La Barre 2305 5 Ellen Ripley Nostromo 2092 6 James T. Kirk Riverside 2233 7 Henry Jones Chica...

How To have Dynamic SQL in MySQL Stored Procedure

How do you build and use dynamic sql in a MySQL stored procedure? ...

Does PHP have a built in mechanism to failover from one database server to another?

I found this: http://www.evolt.org/failover-database-connection-with-php-mysql and similar examples. But is there a better way? I am thinking along the lines of the Automatic Failover Client in the MS SQL Native Client. ...

Teach an M.B.A. the intricacies of Microsoft SQL Server (and how's it different from MySQL?)

I haven't had to interact w/MSSQL much in my development career, though I've spent many an hour working with MySQL. An M.B.A. friend of mine is starting a job where she needs to gain functional knowledge of MSSQL Server, and I'd really like to help. What are the differences between MSSQL and MySQL? How would you recommend a non-techni...

From String to Blob

I am trying to use concat_ws inside a group_concat command. With a query, which simplified looks like: SELECT item.title, GROUP_CONCAT( CONCAT_WS( ',', attachments.id, attachments.type, attachments.name ) ) as attachments FROM story AS item LEFT OUTER JOIN story_attachment AS attachments ON item.id = attachments.item_id GROUP BY ...

How to find all the tables in MySQL with specific column names in them?

I have 2-3 different column names that I want to look up in the entire DB and list out all tables which have those columns. Any easy script? ...

Can't access MySQL server, don't know the password of a root account

For some reason beyond me I can't access the mysql server on a machine. I'm looking at an untouched MT (dv) server with CentOS 5. Any ideas on how to get the root going? ...

When running UPDATE ... datetime = NOW(); will all rows updated have the same date/time?

When you run something similar to: UPDATE table SET datetime = NOW(); on a table with 1 000 000 000 records and the query takes 10 seconds to run, will all the rows have the exact same time (minutes and seconds) or will they have different times? In other words, will the time be when the query started or when each row is updated? I'm...

Where to find a good reference when choosing a database?

I and two others are working on a project at the university. In the project we are making a prototype of a MMORPG. We have decided to use PostgreSQL as our database. The other databases we considered were MS SQL-server and MySQL. Does somebody have a good reference which will justify our choice? (preferably written during the last yea...

MySQLdb execute timeout

Sometimes in our production environment occurs situation when connection between service (which is python program that uses MySQLdb) and mysql server is flacky, some packages are lost, some black magic happens and .execute() of MySQLdb.Cursor object never ends (or take great amount of time to end). This is very bad because it is waste ...

Complex Find in Cake PHP

Hey all I'm hoping someone has enough experience with Cake PHP to make this work. I'm working on something that at the moment could affectionately be called a twitter clone. Essentially I have a set up like this. Users have many friends. This is a many to many relationship to the user table. It is stored in a link tabled called frien...

Should I migrate a MySQL database with a latin1_swedish_ci collation to utf-8 and, if so, how?

The MySQL database used by my Rails application currently has the default collation of latin1_swedish_ci. Since the default charset of Rails applications (including mine) is UTF-8, it seems sensible to me to use the utf8_general_ci collation in the database. Is my thinking correct? Assuming it is, what would be the best approach to ...

Grouping by intervals

Given a table (mytable) containing a numeric field (mynum), how would one go about writing an SQL query which summarizes the table's data based on ranges of values in that field rather than each distinct value? For the sake of a more concrete example, let's make it intervals of 3 and just "summarize" with a count(*), such that the resul...

local rails on Mac OSX loses connection to mysql

On occasion, my local Rails app loses its connection to MySQL. I get some error that the connection failed, but if I just refresh the page, it works fine. This has never happpened in my STAGE or PROD environments (I deploy to Ubuntu), so it has not been that big a deal. Does this happen to anybody else? Is there something I can do to fi...

Kohana PHP, ORM and MySQL BLOBs

I'm trying to create and retrieve a BLOB in a MySQL table via Kohana's ORM library. The code looks something like: $attachment = new Attachment_Model(); $attachment->name = $info['FileName']; $attachment->size = strlen($info['Data']); $attachment->data = $info['Data']; $attachment->mime_type = $info['content-type']; $attachment->save()...

Optimizing single-row queries from large tables in MySQL

I am dealing with MySQL tables that are essentially results of raytracing simulations on a simulated office room with a single venetian blind. I usually need to retrieve the simulation's result for a unique combination of time and blind's settings. So I end up doing a lot of SELECT result FROM results WHERE timestamp='2005-05-05 12:30:2...

Multiple Data Tables in PHP/MySQL?

In asp.net, you can retrieve MULTIPLE datatables from a single call to the database. Can you do the same thing in php? Example: $sql ="select * from t1; select * from t2;"; $result = SomeQueryFunc($sql); print_r($result[0]); // dump results for t1 print_r($result[1]); // dump results for t2 Can you do something like this? ...