mysql

multiple php function instances

I've got a function which calculates some data from a table, a put's it into another, it takes a while for the whole process, about 30 mins or something like that. The function calculates statistics for each day for a couple of months period, but after like 10 days, it starts another thread while continuing another one, and then another ...

How to 'switch' from MySQL to Amazon RDS with minimal application impact?

Amazon officially states: "Amazon RDS gives you access to the full capabilities of a familiar MySQL database. This means the code, applications, and tools you already use today with your existing MySQL databases work seamlessly with Amazon RDS." I don't get this. Amazon RDS is accessible via web services and there a client libraries (li...

java - mysql - select query outfile - where is file getting saved.

connecting to a mysql database from java using jdbc. declaring a query String query = "SELECT *"+ "FROM tt2"+ "INTO OUTFILE 'DataFormatted.csv'"+ "FIELDS TERMINATED BY ','"+ "ENCLOSED BY '\"'" + "LINES TERMINATED BY '\n'"; executing query using executQuery(query). how to change above c...

Facebook like notifications tracking (DB Design)

I am just trying to figure out how facebook's database is structured for tracking notifications. Wont go much into complexity like facebook is. If we imagine a simple table structure for notificaitons notifications (id, userid, update, time); We can get the notifications of friends using SELECT `userid`, `update`, `time` FROM `noti...

Restoring a table in MySQL from multiple dumps

I have a MySQL database that I have performed a couple dumps on. I have these files: dumpA, dumpB, dumpC dumpA contains all the tables at the time of the dump dumpB and dumpC contains only table T Between dumps I truncated table T so dumpA contains the primary keys 1-100 for table T, dumpB 101-200, and dumpC 201-300. I want to resto...

MYSQL stored procedure accessing java object stored as a BLOB.

I am storing a Java object as an byte in a blob of a table. The java object is customized object. How can I construct the java object and use it in the stored procedure? ...

java heap size error for selecting 0.4 million records

i have 2gb ram on my computer. its a windows 7 using eclipse for java when i run a program that runs a select query on mysql database with 0.4 million records it gives heap size error. this is my present eclipse.ini -vmargs -Xmx1000m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=64m what can i do ? ...

MySQL table design

Hi all, I have a table with products. Each product has a title and a price. The products come in huge XML files, on a daily basis. I store all of them in MySQL. But sometimes they have a wrong title. But i can't edit it, because they will be lost the next day (cronjob removes all products and inserts again). What would be the best wa...

Don't use DISTINCT when you have or could use GROUP BY

According to tips from MySQL performance wiki Don't use DISTINCT when you have or could use GROUP BY Can somebody post example of queries where GROUP BY can be used instead of DISTINCT? ...

Duplicate Entire MySQL Database

Is it posible to duplicate an entire MySQL database on a linux server? I know I can use export and import but the original database is >25MB so that's not ideal. Is it possible using mysqldump or by directly duplicates the database files? ...

How mapping of cities in a country-map is done? ( so users can search for ads nearby their cities )

I have a classifieds website. The users first have to specify their 'area of search'... I want to add a function where users also can check a checkbox to find ads 'close' to their selected 'area'. But I don't know how to 'mapp' or 'link' the areas together in a smart way. I need some advice on how to do this... For example, how is 'ra...

Can I use always INSERT ....ON DUPLICATE UPDATE for simple updates/inserts?

(MYSQL) Is there any significant performance differences, or other reasons not to use the INSERT ... ON DUPLICATE UPDATE sql to update by PK/insert new stuff? ...

PHP/MySQL - Need help in correcting a PHP warning?

I found this script on about.com which I'm trying to learn from on how to create a rating system but the script gives me a warning that I listed below. I was wondering how can I fix this problem? And what part of the code do I need to change and where? Here is the warning below. Warning: Division by zero on line 43 Here is the scri...

table transfer from MySQL to MSSQL fails

Hi, I am trying to transfer a table from MySQL to MSSQL using the data migration tool in MS SQL Management studio. I am using .net provider for odbc and selecting the tabel and trying to tansfer. But is is getting the total tables in the database but when I try to transfer it gives error. Even when I try to preview the data, it says, ...

Shell Script to update multiple databases

This is what I currently have: #!/bin/bash # Shell script to backup MySql database MyUSER="root" MyPASS="password123" MYSQL="$mysql" MYSQLDUMP="$mysqldump" # Store list of databases DBS="" # Get all database list first DBS="$($MYSQL -u $MyUSER -h -p$MyPASS -Bse 'show databases')" for db in $DBS do The problem i have is the 'do' b...

Trying to filter a mysql table by date using a single query.

Hi there, i'm trying to request any records from a table that appear on or after todays date, using a single query. All the dates for each record are stored in seperate columns eg. - one for 'month', one for 'year', and one for 'day'. obviously i've been getting all records that occur after the year in today's date $sql = "SELECT * FRO...

every derived table must have its own alias

i am running this query on mysql SELECT ID FROM (SELECT ID, msisdn FROM (SELECT * FROM TT2)); and it is giving this error: Every derived table must have its own alias. what is wrong ? ...

PHP & MySQL rating script page problem?

I found this script on about.com which I'm trying to learn from on how to create a rating system but the script for some reason wont count a vote when the link is clicked and will send me to a page that says not found. The page should just reload to itself and count the vote> I was wondering how can I fix this problem? And what part of ...

MYSQL - Query items that match date

I'm making a Calendar in PHP, and I have a for loop for 31 days (or depending on how many days are in the month), each day is written out with $listDay. In my MySQL database, I have a field called 'eventDate' with a unix timestamp, and I have a variable $event_day built from the timestamp just for the day. I can't figure out how to wri...

Issues running a stored procedure through SQL script, used to work until I changed one of the parameter from Varchar to Int

I hope somebody can help me here, I have a table that has the name of the Stored Procedure that I would like to run, it also has a parameter that I would like to pass through into the Stored procedure. declare @RowCnt int declare @MaxRows int declare @ExecSql nvarchar(255) select @RowCnt = 1 These next two rows are specific to sourc...