mysql

MySQL + Windows VISTA / 7 = Crashes with Eclipse RCP + Datanucleus app.

Hi there. I'm having a big problem with MySQL + Datanucleus + Windows Vista / 7. THE Problem is so SEVERE, the MySql Server Shuts Down! PROBLEM OCCURS: with DN 1.0.0.m3 + MySQL 5.1.x (LOCAL) + Vista. when performing deletePersistent of an object that has a LIST in the structure (a deletePersistentAll of the LIST is issued BEFORE del...

Unable to make a MySQL database of SO questions by Python

Brent's answer suggests me that has made a database of SO questions such that he can fast analyze the questions. I am interested in making a similar database by MySQL such that I can practice MySQL with similar queries as Brent. The database should include at the least the following fields (I am guessing here, since the API of SO's api...

PHP PDO prepared query won't return results from for loop

Hi, I have the following code: $link = new PDO("mysql:dbname=$databasename;host=127.0.0.1",$username,$password); $query = $link->prepare("SELECT * FROM index WHERE sbeid=:idvar"); for($j = 1; $j < count($array); $j++) { if($array[$j][16] == "TRUE" || $array[$j][16] == "FALSE") { $paramforquery = $array[$j][25]; ...

mysql - subqueries and joins

Hey, I'm not quite sure if this is the right approach, this is my situation: I'm currently trying to select 15 galleries and then left join it with the user table through the id but I also want to select one random picture from each gallery however from what I know you can't limit the left join (picture) to only pick up one random pict...

Total amount of columns in mySQL !

hi , i have this sql : SELECT * , ( xnum * xprice ) AS amount, SUM( xnum * xprice ) AS total FROM xxbasket LEFT JOIN xxsubproduct USING ( xsubproduct_id ) LEFT JOIN xxcolor USING ( xcolor_id ) WHERE xuserid = '3' when i use SUM( xnum * xprice ) AS total it's gives me only one row , but when i remove this SUM( xnum * xprice ) it's g...

Error creating MySQL table

Hi, I get an error when running the following create table: CREATE TABLE Event ( id VARCHAR(10) NOT NULL, title VARCHAR(100), start_date DATE NOT NULL, end_date DATE, description TEXT, url VARCHAR(200), website VARCHAR(200), location VARCHAR(32) NOT NULL; PRIMARY KEY (id), FOREIGN ...

Help with Join

I need help with a join I think. Can't figure it out. I have these tables: Posts `id` int(10) unsigned NOT NULL, `title` varchar(140) DEFAULT NULL, `text` text COLLATE utf8_unicode_ci Posts tags `post_id` int(10) unsigned NOT NULL, `tag_id` int(10) unsigned NOT NULL Tags `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varc...

How to create "Upcoming birthdays" module in Rails?

Hi, I have a table "users" with a column "date_of_birth" (DATE format with day, month, year). In frontend I need to list 5 upcoming birthdays. Spent ages trying to work out the logic.. also browsed every possible article in Google with no luck.. Any suggestions how to do this in RoR? Thanks! ...

MySQL - Getting search results from table and referencing tables

Hey everyone, (Using MySQL and PHP) I have a search form that will allow my users to type in a string, and search that string on a particular criteria. My problem is that a user needs to be able to search for information that is "spread" across multiple tables. For example: -Table "users" contains fname, lname, role, username (PK) -...

Suggestions for backing up php site and mysql db

Hi, do you have any good suggestions how to backup remote php site and mysql, and upload it to another remote ftp? I do have shell access and it is linux system. Kind of lame question when I post it like that, but I assume some script would have to be run on remote server with site, that would do this. If you don't mind sharing your i...

Calculating percentile rank in MySQL

Hi, I have a very big table of measurement data in MySQL and I need to compute the percentile rank for each and every one of these values. Oracle appears to have a function called percent_rank but I can't find anything similar for MySQL. Sure I could just brute-force it in Python which I use anyways to populate the table but I suspect t...

Synchronization with master database

I have a 2 databases hosted on the different server. What the best thing do, to copy all the contents of master table database to the table of slave database? I am not the owner of the master database but they are willing to give an access. Before the data from master database is outputted via RSS and my PHP script parse it to insert int...

Implementing A Ranking System

I've seen several question on how to secure and prevent abuse of ranking systems (like staring movies, products, etc) but nothing on actually implementing it. To simplify this question, security is not a concern to me, the people accessing this system are all trusted, and abuse of the ranking system if it were to happen is trivial and e...

How to deal with silent mysql sum() integer overflow?

I've got this table with an int(11) column and hundreds of millions of rows. When I run a query like SELECT SUM(myIntColumn) as foo FROM myTable; the return value does not make sense--it is smaller than the the single largest max value. My values for this column max out somewhere around 500m, and the signed int should be able to ha...

join table more than once in the same query?

Hi, I'm looking for some help on constructing a query. I have three tables like this: Products id | (20 other columns I don't need) 1 product_names product_id | product_name 1 my product 2 my second product 3 my third product cross_sell_products (where each product may h...

Mysql Compare two datetime fields

Hi All, I want to compare two dates with time, I want all the results from tbl where date1 > date2 Select * From temp where mydate > '2009-06-29 04:00:44'; but it is just comparing dates not time. it is giving me all the result set of today's date '2009-06-29 11:08:57' '2009-06-29 11:14:35' '2009-06-29 11:12:38' '2009-06-29 11:37:48...

giving javascript/the server time to process

Hello all, I've got a confusing problem. I'm working on a music catalog/playlist/player. When a user drags a song into the playlist a request is sent to php (via javascript/ajax) which finds the song in the database and returns song information which is then organized and displayed in the playlist. This works great. The problem I'm havin...

Cannot unserialize object after storing it serialized in database!

I'm trying to store a complex object here and am doing that by serialising the object running a mysql_real_escape_string on it and inserting it into a mysql database. However when I retrieve it running a sql query - I'm using Zend frameworks Zend_DB_Table here but anyway - and when I try to stripslashes and unserialize I dont get my obj...

disabling re-use of deleted records in Mysql

I have a web application where I interact with a MySql database. When I delete a record, it seems that its slot is reused the next time I create a new record. Since each record has a sequential primary key, the next record will have a new key say 5, but the new record will be placed in the last emptied spot, say where record number 2 use...

Need to find out of a table has certain columns before running alter table

I am writing a plugin for wordpress. When the plugin is initialised I need to find out if the users table contains the columns I am trying to insert to ensure I am not overwriting anything. Can someone provide me with the syntax that does this; I think it looks something like this: SELECT DISTINCT TABLE_NAME FROM INFORMATION_SCHEMA...