mysql

Need help creating a view that contains two different sums

I have a view that's currently defined as CREATE VIEW riders AS select ridelog.uid AS rid,sum(ridelog.distance) AS distance from ridelog group by ridelog.uid What I'd like to do is add a second field that shows the distance y-t-d. i.e, the sum of the distances for rides that occurred since January 1st of the current year. The problem ...

mbox to mysql

Hey Everyone, Has anyone come across a way to import the contents of mbox files (10 megs or so) into MySQL? Thanks, j ...

Opening, Rotating, and Storing Tiff Images In a MySQL Database Blob Column

My problem is rather straight-forward: Retrieve an image from a MySQL database (currently stored as binary data in a blob column) Rotate that image 90 degrees (using PHP's imagerotate) Store the image back in the database with that rotation changes applied. I'm having trouble finding functions that will let me save the image as a da...

Update script stops randomly

I'm working on a one-time PHP (5.2.6) script that migrates several million of MySQL (5.0.45) database rows to another format in another table while keeping (a lot) of relevant data in memory for incremental calculations. The data is calculated incrementally. (in chunks of about 1000 lines) The script stops unexpectedly in random points ...

MySQL MD5 and Java MD5 not equal

The next function in MySQL MD5( 'secret' ) generates 5ebe2294ecd0e0f08eab7690d2a6ee69 I would like to have a Java function to generate the same output. But public static String md5( String source ) { try { MessageDigest md = MessageDigest.getInstance( "MD5" ); byte[] bytes = md.digest( source.getBytes("UTF-8") ); ...

Whats a good way about troubleshooting a script in terms of performance (php/mysql)?

I've written a site CMS from scratch, and now that the site is slowly starting to get traffic (30-40k/day) Im seeing the server load a lot higher than it should be. It hovers around 6-9 all the time, on a quad core machine with 8gb of ram. I've written scripts that performed beautifully on 400-500k/day sites, so I'd like to think Im not ...

How to save portlet positions

Hello, I will be using jQuery's functionality to create portlet widgets for my web application suit. I haven't started as of yet, but will do soon, so this is the planning Now, currently, the page loads, and the widgets load into their default positions. A user can move them around, change their settings, whatever. Now, my problem is t...

How can I select only one row for each ID in MySQL?

I have a MySQL table that holds many entries with repeated IDs (for various reasons) So you might have something like ID TIME DATA 1 xx xx 2 xx xx 3 xx xx 1 xx xx 3 xx xx What query can I run through PHP to select each ID only once? So I would like my result set to look like ID TIME DATA 1 xx xx 2 xx xx 3 xx x...

backend db setup for an app with geographically diverse users

The in-house developed software where I work connects directly to a mysql server here in our office via our devexpress orm (XPO). Performance is great. We're opening another office... cross country. Performance: not so great. The requirement is that the software be as responsive in both offices as it is in this office and that the data ...

Make all form validation errors show up at top in symfony?

I think I may be missing something here that should be relatively common. How can I make all form validation errors, including field-bound errors, show up at the top of the form (global)? ...

Using Guid as Id column in NHibernate causes format exception when using MySQL

When I define the NHibernate entity/mapping to use Guid as identity column I receive an exception. The Guid column is generated as a varchar(40), but the content seem to be binary. Is there a solution to this? For now I'm just using plain ol' int, but it would be nice to know for future projects! :) ...

How to force adodb php library to use lowercase field names

I'm trying to use adodb for db access in my webapp. However my hosting provider has mysql case sensitive, and I have all my fields in lowercase. But when I call getInsertSQL function, I got them in uppercase. Is there a way to force adodb to use lowercase? I tried with define('ADODB_ASSOC_CASE', 0); $ADODB_ASSOC_CASE = 0; But it se...

Can a many-to-many join table have more than two columns?

I have some tables that benefit from many-to-many tables. For example the team table. Team member can hold more than one 'position' in the team, all the positions are listed in the position db table. The previous positions held are also stored for this I have a separate table, so I have member table (containing team details) positions...

CONCAT'ing NULL fields

I have a table with three fields, FirstName, LastName and Email. Here's some dummy data: FirstName | LastName | Email Adam West [email protected] Joe Schmoe NULL Now, if I do: SELECT CONCAT(FirstName, LastName, Email) as Vitals FROM MEMBERS Vitals for Joe is null, as there is a single null field. How do you ov...

MySql Leap Years

I have a MySql table called reviews which stores a lot of product reviews, accumulated over many years, each annotated with a date timestamp. I wanted to draw a bar-chart showing me the number of reviews I have accumulated on each day of the year, hoping to find the important dates for my system. I used this query select dayofyear(da...

Postgresql: Update timestamp when row is updated

In Mysql, we can execute this where it updates the changetimestamp every time the row is changed. create table ab (id int, changeTimestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP ); Is there something similar to do the above in Postgresql? ...

Upgrading SQL Server 2000 to MySQL 5.1 using DTS - How solve DateTime problem?

I'm trying to migrate from sql server 2000 to mysql by using DTS. That's the best tool I know yet. But one a sql server tables has a column with datetime type, the DTS suggest the following sql code: `StartDate` long varbinary NULL, `EndDate` long varbinary NULL, It should be: `StartDate` DateTime NULL, `EndDate` DateTime NUL...

What are the diffrences between utf8_general_ci and utf8_unicode_ci?

I've got two options for unicode that look promising for a mysql database. utf8_general_ci unicode (multilingual), case-insensitive utf8_unicode_ci unicode (multilingual), case-insensitive Can you please explain what is the difference between utf8_general_ci and utf8_unicode_ci? What are the effects of choosing one over the other when...

What are server SQL modes?

What are server SQL modes? ...

Why the rows returns by "explain" is not equal to count()?

mysql> select count(*) from table where relation_title='xxxxxxxxx'; +----------+ | count(*) | +----------+ | 1291958 | +----------+ mysql> explain select * from table where relation_title='xxxxxxxxx'; +----+-------------+---------+- | id | select_type | rows | +----+-------------+---------+- | 1 | SIMPLE | 1274785 | +---...