mysql

Group by named column

I always forget how to do things like this. I have a database table with birthdates and I want to find out how many people have the same age. I'm trying: SELECT TIMESTAMPDIFF( YEAR, birthdate, CURDATE( ) ) AS age, COUNT( age ) FROM person GROUP BY age but get the error Unknown column 'age' in 'field list' How can I do a gr...

Mysql: Query to find row with max with tie breaker

User Region Points Last_Updated 1 5 0 1-Nov-09 I want this row 2 1 5 30-Oct-09 3 1 2 02-Nov-09 2 2 7 02-Nov-09 and this row 3 2 5 02-Nov-09 Using a mysql database, I want to gra...

PHP - Remove whitespace from within a string.

I get a string from a db, then I remove all the HTML tags, carriage returns and newlines, before I put it in a csv. Only thing is I cant remove the excess white space from between the strings, any ideas? Thanks, Joe ...

ASP.NET and C# constant processing behind the site possible?

Imagine a site where the user logs in and can view their ip webcam (I can do this bit i believe). The problem is i want the site to do some processing on the images/video coming in even when the user is not logged in i.e run some motion detection algorithm and if there is motion log the incident in a database. What would i need to learn...

How to store Euro Symbol in mysql database ?

How to store symbol for Euro currency in MySQL Database ? ...

Wrestling with SQL

I have this in a MySQL db: table Message sender_id int recipient_id int created datetime [title, body, etc... omitted] Is it possible to get from this, in a single query, a list of all the users who have been communicating with a given user with id N (meaning N appears in either sender_id or recipient_id), ordered by c...

Business Logic in PHP or MySQL ?

On a site with a reasonable amount of traffic , would it matter if the application/business logic is written as stored procedures ,triggers and views , instead of inside the PHP code itself? What would be the best way to go keeping scalability in mind. ...

Merging data from two different data sets (Facebook & MySQL)

I'm wondering if this is the best way to tackle this issue. I am merging a Facebook users friends data, (from facebook - returns a multi array) with the votes from the users in that list that voted (from MySQL). This is how I accomplished this. I'm a junior developer and looking for help on making my code as optimized as possible. ...

What is this error? "Database query failed: Data truncated for column 'column_name' at row 1

I'm building a PHP/MySQL application and I'm running into a problem with my create and update query. I have 5 columns that are set to type FLOAT that are also set as NULL columns. I don't plan to fill them in until much later in the workflow. However, I need to create new records for this database, and I need to edit existing records, ...

Gathering all emails from table for email

Hello, I would like to build a webpage that follows the system in vBulletin of emailing. So, currently, the user table contains the user data: username, userfullname, useremail etc. Basically, what I need is for this script to gather the emails of the users from the database. Additionally, I'd like the email to be sent out invididuall...

Selecting the next date in MySQL

I have a list of dates in a table in a MySQL database (the dates when a charity bookstall is to be held), which I want to display on a page. On one page I'm displaying the date of the next stall, and on another the dates of the stall in the next month. (Currently I'm using an unordered HTML list and selecting the dates with PHP, but it's...

Multiple columns (one per type) vs. single TEXT/Clob column

I need to store some diffs of other tables' columns in the database. I want to use a single table. Option A Table with 4 columns: id content_type (VARCHAR 255, will be: datetime, integer, varchar, text/clob ...) old_content (CLOB / TEXT, software serialized data for content-type) new_content (CLOB / TEXT, software serialized data for...

Django modify DATABASE_HOST at runtime

I am trying to switch between 2 mysql servers at runtime. I do not need to maintain both connections alive all the time. This is what I am doing from django.conf import settings from django.db import connection from django.contrib.auth.models import User connection.close() setattr(settings, 'DATABASE_HOST', 'mysql1.com') list1 = User....

Implementing cross-thread/process queues in Perl

What is the most efficient way of implementing queues to be read by another thread/process? I'm thinking of using a basic MySQL table with polling on sleep. This sounds to be the most scalable (it doesn't even have to be on the same server) but might potentially result in too many queries to the DB. ...

Questions about iPhone emoji and web pages

 Okay, so emoji basically shows the above on a computer. Is that another programming language? So how do I put those little boxes into a php file? When I put it into a php file, it turns into question marks and what not. Also, how can I store these in a MySQL without it turning into question marks and other weird thing...

Is there a reason to use two databases?

Is it because of size? By the way, what is the limit of the size? ...

Is there a MySQL equivalent of PHP's preg_replace?

I have a to match a field in MySQL, for which I thought I could use a regular expression, but it appears that MySQL doesn't have the functionality I need to do the job. Here's the scenario: I have a variable in PHP called $url. Let's say this variable is set as the string "/article/my-article/page/2". I also have a table of URLs in M...

Python Twisted and database connections

Hi all, Our projects at work include synchronous applications (short lived) and asynchronous Twisted applications (long lived). We're re-factoring our database and are going to build an API module to decouple all of the SQL in that module. I'd like to create that API so both synchronous and asynchronous applications can use it. For the ...

date problems in mysql 5.1.40

I upgraded from 4.1.8 to 5.1.40 and am having a problem with queries where the dates contains single digit day or month. The first query below worked fine before on 4.1.8 - also if I create a new table in 5.1.40 it works fine, but not on the upgraded data. Dumping and re-creating tables isn't an option. Any ideas how to correct? mysql [...

Is searching PHP array faster than search/retrieve from MySQL

Was curious to know which is faster - If i have an array of 25000 key-value pairs and a MySQL database of identical information, which would be faster to search through? thanks a lot everyone! ...