mysql

MySQL charset conversion

Hello, I have a database in which all text fields and tables have 'utf8' specified explicitly as default character set, however data in this database is stored as 'cp1257'. I can display symbols only when I use SET NAMES 'cp1257' or \C cp1257. Trying to display them without those instructions fails, because it tries to fetch data as 'utf...

MySQL - Combine two fields to create a unix timestamp?

Hi, I'm trying to retrieve a UNIX timestamp from a query by combining a date and a time field in the table, however it keeps returning as zero. SELECT *, UNIX_TIMESTAMP(startdate starttime) AS start, UNIX_TIMESTAMP(enddate endtime) AS end FROM mytable; Can anyone help me out? Thank...

Is MySQL InnoDB is appropriate for this scenario?

My MysQL database contains multiple MyISAM tables, with each table containing millions of rows. There is a heavy insert load on the database, so I cannot issue SELECTs on that live database. Instead, I create a replica of the database for queries and conduct analysis on that. For the analysis, I need to issue multiple parallel queries....

How to store array data in MySQL database using PHP & MySQL?

I'm new to php and mysql and I'm trying to learn how to store the following array data from three different arrays friend[], hair_type[], hair_color[] using MySQL and PHP an example would be nice. Thanks Here is the HTML code. <input type="text" name="friend[]" id="friend[]" /> <select id="hair_type[]" name="hair_type[]"> <option ...

Mac OS X & MAMP - How to run mysql without having to type in the full path?

Right now, if I want to run mysql, I have to do /Applications/MAMP/Library/bin/mysql -u user -ppass... I'd be a happy camper if I could just do mysql -u user -ppass.... Been googling around, but haven't been able to find anything... Have a feeling I'm using dumb search terms, so if anyone here knows how to do this, that'd be awesome......

View all foreign key constraints for entire MySQL database

I have a large database with over 150 tables that I've recently been handed. I'm just wondering if there is an easy way to view all foreign key constraints for the entire DB instead of on a per-table basis. ...

MySQL DATE_ADD usage, 5 day interval

I'm trying to select the order total sum ($) and invoice count over a 5 day period in a single query. I can't seem to get this to happen though. The current query I have is here... SELECT COUNT(id) as invoice_count, SUM(orderTotal) as orders_sum, UNIX_TIMESTAMP(created) as created FROM ids_invoice WHERE DATE_ADD(created, I...

Linking Post Title to Specific Page ID

I've created a form to update my websites homepage with content but I wanted to know how I could set it up so that a posts title links to a specific post ID. I'd also like to add a Read More link that directs anybody reading the blog to the correct post. Here is my PHP code: <html> <head> <title>Blog Name</title> </head> <body> <...

Saving dynamically added text input to MySQL.

Hey all, using this method http://stackoverflow.com/questions/1501181/jquery-append-and-remove-element i'm adding text inputs to a document. i'm using this php if($_POST['cp_slider']) { $array=$_POST['cp_slider']; foreach($array as $cp_slider) { if(strlen($cp_slider)>0){ echo '<li><input type="text" name="cp_slider[]" value="'.$this->op...

Avoid multiple LEFT JOIN

Is there a way to avoid adding a second LEFT JOIN for the table "social_mcouple" to query where social_members.m_id = social_mcouple.c_id below? $res = @mysql_query("SELECT *, DATE_FORMAT(m_lld,'%m/%d/%y') AS m_lld_formatted FROM social_members LEFT JOIN social_member_types ON t_id=m_type WHERE m_user='".$en['user']."'"); ...

InnoDB - roll back all transactions for connection

Is it possible to rollback all statements that have been executed in the same connection thread? Instead of ROLLBACK just reverting the last executed statement. ...

How can I pull multiple rows from a MySQL table and use all of them automatically for the same thing?

Basically, I have multiple URL's stored in a MySQL table. I want to pull those URLs from the table and have cURL connect to all of them. Currently I've been storing the URL's in the local script, but I've added a new page that I can add and remove them from the database, and I'd like the page to reflect it appropriately. Here is what I ...

easy mysql query question

Hi, here is the "msg" table on mysql sent_to customer msg read ------- -------- ------ ----- 45 3 bla 0 34 4 bla 1 34 6 bla 0 45 3 bla 0 56 7 bla 1 45 8 bla 0 for example user whose id number ...

Join DELETE in MySql? How to?

I have this: $query="DELETE FROM classified, $sql_table WHERE classified.ad_id = '$id' AND classified.classified_id = $sql_table.classified_id AND classified.poster_password='$pass'"; I get this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ...

How would I do this in MySQL?

Lets say I have a database of widgets. I am showing a list of the top ten groupings of each widget, separated by category. So lets say I want to show a list of all widgets in category A, but I want to sort them based on the total number of widgets in that category and only show the top 10 groupings. So, my list might look something lik...

Hows does Drupal 6 interact with MySQL for connections and transactions?

Hows does Drupal 6 interact with MySQL for connections and transactions? Does connection pooling get used? How are transactions handled? At what level are these things managed by Drupal vs being handed off to be handled by MySQL? I did a good amount of searching on the web and within Stack Overflow, but mainly, I only found articles ...

Problems with MYSQL database

I edited the code and now the page loads and everything, but it does not insert into the database: <body> <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { require("serverInfo.php"); mysql_query("UPDATE `cardLists` SET `AmountLeft` = `AmountLeft` + ".mysql_real_escape_string($_POST['Add'])." WHERE `cardID` = '".mysql_real_escape_...

Connection failed with MySQL .NET Connector

I cannot connect to MySQL it fails on line connection.Open(), is there something wrong with my code ? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using MySql.Data.MySqlClient; namespace MySQLConnection { public p...

Resetting AUTO_INCREMENT on myISAM without rebuilding the table

Please help I am in major trouble with our production database. I had accidentally inserted a key with a very large value into an autoincrement column, and now I can't seem to change this value without a huge rebuild time. ALTER TABLE tracks_copy AUTO_INCREMENT = 661482981 Is super-slow. How can I fix this in production? I can't get ...

Monitor MySQL table for changes within a C# program?

Is it possible to monitor a mysql table for changes within a c# application? I basically want an event to be raised when data is inserted into the table. The only thing I can think of now is to query the table every 100ms or so. ...