mysql

Easiest way to copy a MySQL database?

Does anyone know of an easy way to copy a database from one computer to a file, and then import it on another computer? ...

mysql date storage & query performance with php

I've got a database of historical records from WW2 and currently each recorded event's date is stored in one integer field as YYMMDDHHMM. This makes simple tasks like ORDER BY, or searching for all events within a certain time period extremely easy. However, if somebody wants all events that occurred on December 1st in any year of the wa...

Add row in one table for every nth entry in another table

Basically what I have is a system where users get rewarded for every 10 comments. So, in the db, one table captures the comments, and the other a reward for every 10th comment added. For instance, if a user has added 40 comments, they will have 4 rewards/4 rows in table 2. It sounds so simple to me, but I can't seem to figure it. Though...

mysql - update foreign key with a value

I have a birthdate, year, month, day columns where columns "year,month,day" are foreign key to other tables What I want to do is for each birthdate get id(year(birthdate)) to be the value of year column and the same thing for month and day columns. How can I do this in MySQL? i tried this solution: update member set year=(select All_y...

mysql counting results between two datetime

Hey All, Really hope this can be done but I have come across a problem I need to resolve. I have an Inventory booking system for items. Each item gets booked in and out by hours. So some may go in and out within a few hours while others may be days. So in my column I have 2 datetime fields out | in. But I may have multiple items so in...

Problem with MySql INSERT MAX()+1

I have a single table containing many users. In that table I have column called user_id (INT), which I want increment separately for each person. user_id MUST start at 1 I've prepared a simple example: Showing all names +--------------+-----------------------+ | user_id | name | +--------------+-------------------...

Django: How to model a MySQL VARBINARY HEX Field? (solved)

I am trying to model a VARBINARY MySQL field in Django v1.1.1. The binary field stores a hexadecimal representation of data (i.e. one would use INSERT INTO test(bin_val) VALUES X'4D7953514C') Reading the Django documentation[1] I came up with this sollution: class MyTest(models.Model): bin_val = BinValField() class BinValField(mod...

INSERT LOW_PRIORITY or INSERT DELAYED in Hibernate

Hi guys, How do I do a low_priority or delayed insert into a MySQL table with Hibernate? In my logging routine I want to insert the log info to a table in my database for further analysis. But I don't care about how long it takes for the insert to be done, so usually I would say INSERT LOW_PRIORITY INTO LogEntry (level, title, full) VA...

Does mySQL Replication: Master DB Name has to be the same as the Slave DB name??

I have set the Master DB Name as MDB & in the Slave server I set to replicate-do-db=SDB <-- this did not work? But when I set it up as the same DB name it works. Is there any solution out there to setup 1 master db with 2 different slaves but in the same server?? ...

What is the best mysql table format for high insert load?

I am in the process of adding a new feature to a system. The process will read live data from PLC´s and store them in a database. The data table will have 4 columns: variable_id (SMALLINT), timestamp (TIMESTAMP), value(FLOAT), quality(TINYINT). The primary key is (variable_id, timestamp). The system needs to be able to insert 1000-2000...

Connected to mysql instance ONCE or TWICE?

Hello there, I was wondering whether the following command (from a .bat script): (1) connects to the mysql instance once and then executes script#1 followed by script#2, or (2) does it reconnect for each of the sql scripts? mysql -B -b -h%HOST% -u%USER% -p%PASSWORD% %SCHEMA% < "scripts\create_and_populate.sql" < "scripts\update_joomla_...

MySQL dot-traversal... possible?

So I'm working on a CMS that will allow users to "traverse" through database tables. I'm having some trouble implementing it though, and am wondering if anyone has any suggestions. Table: house name (varchar), town (relationship, using the rel table) Table: town name(varchar), state (relationship, using the rel table) Table: state na...

MySQL - How to ORDER BY RELEVANCE? INNODB Table

I've got about 20,000 rows in an INNODB table called 'cards', so FULLTEXT is not an option. Please consider this table: id | name | description ---------------------------------------------------------- 1 John Smith Just some dude 2 Ted Johnson Another dude 3 Johnathan Todd This guy too...

mysql adjusting datetime values in the dbase, not in search returns

This must be a ridiculously stupid question, because after numerous searches of the StackOverflow question archives (and elsewhere) I can't find an answer. I recently posted a question about managing date & time data here: http://stackoverflow.com/questions/1587116/mysql-date-storage-query-performance-with-php Following Mike B's advic...

get current date with PHP help

Hi.. Is there any script to check the current date in PHP? I want to use this function to display a date from mysql db, and if the date from the db is the same as todays date, then display "TODAY" instead... Thanks... ...

a little more help in this simple script about date() function in PHP

Hi. why wont this work? this is in a while loop: $postdate = date( "j F", strtotime( $row['insert_date'] ) ); if ($postdate == date("j F")) {$postdate = "today"}; $table .= bla bla bla "$postdate"; it gives an error on the 'if statement line' in my browser... $postdate is something like 14 october before the if statement! Thanks ...

Why can't I do SHOW PROCESSLIST with QtSql (PyQT)?

I am a Python and QT newbie. I am trying to do a little app with PyQT4 in order to supervise a home MySQL server of mine, so my first idea was to do the classic SHOW PROCESSLIST, parse it, and show in a pretty UI. Nothing big, really. But for some reason, the QtSql module doesn't return anything when doing this query, although it works ...

SQL: deleting tables with prefix

Hello, i know how to delete my tables in MySQL, DROP TABLE but now i need to know how to delete my tables who all have the prefix myprefix_ How to? --I NEED TO DO THIS IN PHPMYADMIN, IN A BROWSER. NO TERMINAL STUFF PLEASE. BATCH STUFF IS ALWAYS APRECIATED.-- ...

.Net Framework Data Provider not found on host.

I have a working web site using Linq to Entities, on a MySQL database. Last night I installed the MySQL connector 6.0 for .NET, and all was good on my local machine. I assume I now have some GAC to Bin migration to do on the host. Does anybody know what files I must transfer and what I must do to my web.config? ...

MYSQL: Two Table SELECT without common values

I need a query to make a Select over table1 and table2. I want them to appear as a common result, but without any connection there is no value from table 1 that corresponds with any value from table 2. So if a result was from table1 it should contain the values table1.a , table1.b, table1.c if it comes from table2 it should have table2...