mysql

mysql replication duplicated entry

Is it recommended to add the slave-skip-errors = 1062 option into the my.cnf file? I want to keep my data consistent. Thanks for your opinions. ...

Retrieving MySQL records based on a variable set of points of comparison.

Let's say I have a MySQL table, people. Each record comprises a variety of properties, among these favourite_colour, country, and age_group. What I would like to do is retrieve records from this table by their similarity to a set of specific parameters. Given "Red", "United States", and "18-25", for example, the best results would be th...

MySQL table modified timestamp

I have a test server that uses data from a test database. When I'm done testing, it gets moved to the live database. The problem is, I have other projects that rely on the data now in production, so I have to run a script that grabs the data from the tables I need, deletes the data in the test DB and inserts the data from the live DB. ...

How to get an AutoNumber from DataTable AutoIncrementColumn with a Strongly-Typed Database in c#?

I have added a strongly-typed Database (MySQl) to a C# (.net 3.5) project. The database (DB.Electrophysiology_Data) has several relational tables but basically I want to add a new 'filesRow' to the 'files' table. I use something like the following code. DB.Electrophysiology_Data.filesRow new_file = ds.files.NewfilesRow(); ...set the va...

mysql UNION vs IN clause

I have been trying to optimize one of my queries which looks like: select toc.* from (select sender, max(convid) as maxconvid from MetaTable where sender in ('arjunchow','aamir_alam') group by sender) as tmp1 inner join MetaTable as toc on toc.sender = tmp1.sender and toc.convid = tmp1.maxconvid...

Executing Line/Multiple Lines Only in mySQL Query Browser

I already used Microsoft SQL Server 2005 and found really easy to execute single/multiple lines of an sql query. Example: insert into tablea ($vala, $valb, $valc) values ($vala, $valb, $valc); insert into tableb ($vala, $valb, $valc) values ($vala, $valb, $valc); How can I execute the second part only? In MSSQL i will highlight the...

JQuery - web form to mysql via php - textfield not formatting correctly.

Can anybody suggest the best way of keeping the formatting intact of a text field - ie. keeping the line breaks or carriage returns in mysql and then recognising them when the form is populated on login? Currently when the textfield data is stored (in a TEXT field in mysql) its losing the carriage return values and adding a small square...

It is possible to get MySql working with ASP.Net MVC using the Subsonic template?

I've downloaded and installed the latest ASP.Net MVC framework, and installed the Subsonic project template. The template understandably comes installed with support for MS-SQL server only, and I'm wondering if anyone has created version of the .tt template files to cater for a MySql connection? I've added the MySql connection string to...

mysql time and php time not the same

Hi - When I use current_timestamp with MySQL, I get the correct time, but when I use $mysqldate = date( 'Y-m-d H:i:s' ); I get the date with with an hour delay (eg, 4:42 PM is 5:42 PM). I understood that both function use the server's local time - can someone explain the difference? Thanks. ...

How can I change an URL inside a field in MySQL?

I have a table called "wp-posts" with a field "post-content". This field contains the text for a blog posts. I'd like to change all records to replace an URL for another one. Imagine that I can have things like: This is a test and somewhere there's something like <img src="http://oldurl.com/wp-content/somimg.jpg"&gt; and something l...

MySQl change auto increment Starting number?

Hi I have a dataset and I want to start and auto increment field at 5 not 1 is this possible? cheers JJ ...

SQL that list all birthdays within the next and previous 14 days

I have a MySQL member table, with a DOB field which stores all members' dates of birth in DATE format (Notice: it has the "Year" part) I'm trying to find the correct SQL to: List all birthdays within the next 14 days and another query to: List all birthdays within the previous 14 days Directly comparing the current date by: (D...

MySql Foreign Key index

Hi, I am using a Mysql table products which has a foreign key category_id on the categories table the foreign key constraint is defined (Innodb engine). I noticed that when I run EXPLAIN SELECT * from products where category_id=1; it uses the foreign key, so I see type=Range and Key: my_foreign_key But when I run EXPLAIN SELECT * f...

how to dump latin1 encoded tables to utf8 encoded tables in MYSQL?

I can dump the data through phpmyadmin, then use $utf8 = iconv('latin1','utf-8//IGNORE',$latin1); to convert it into utf8 encoding, but see many messy code ...

How is the sausage made tour of apache/php/mysql interaction

I am having trouble understanding how apache/php/mysql stack works on a low level (including interaction with the browser). Is there a good description somewhere (a book, a website, etc) that will walk me through the whole path and explaining how starting with a browser reqesting a url, http requests is being sent, how apache talks to ph...

copy MySql DB from one server to another

Hi, I need to copy a MySQL DB from a server on Linux to a server on Windows. I've tried using mysqldump but it doesn't seem to include Stored Procs. I want to copy everything, i.e. schema, data, stored procs, triggers, etc. Thanks, Don ...

Data Corruption with MediumText and ASP/MySQL

I have a website written in ASP with a mySQL database. ASP uses the ODBC 5.1 driver to connect to the database. Inside the database there is a varchar(8000) column (the length started small, but the application has evolved A LOT since its conception). Anyway, it recently became evident that the varchar column should be changed into a MED...

how can I select from one table based on non matches in another in mySQL

I have two tables ITEMS : id, name CATEGORIES: items_id, category I need to select all the items whose IDs are NOT in the CATEGORIES table. I suspect it's really simple, but can't figure out the syntax. ...

calculate frequency using sql

I have a table in MySQL: Col1 | Col2 a A a B c C a B i want to create a table like this: col1 | col2 | freq a A 0.33 a B 0.67 col1 is a specified item in Col1. col2 is distinct item that has occured with the specified item(i.e. a). freq column is the frequency of appearence...

add column to mysql table if it does not exist

My research and experiments haven't yielded an answer yet, so I am hoping for some help. I am modifying the install file of an application which in previous versions did not have a column which I want to add now. I do not want to add the column manually, but in the installation file and only if the new column does not already exist in t...