mysql

GRANT DELETE ON database.table TO username@'%';

Hi, I have given a user full control over one table in a database. Hoever it appears they cant delete records. I've tried as a privilaged user: GRANT DELETE ON databasename.tablename TO username@'%'; flush privileges; But delete stil doesn't work ERROR 1142 (42000): DELETE command denied to user 'username'@'localhost' for table 'ta...

How does Facebook achieve good performance?

Almost everyone has a Facebook account, even people who are not familiar with the Internet. With millions people actively using Facebook, updating their status, replying to messages, uploading photos and so on, how is Facebook's page still loading very fast? I was told that Facebook was built using only PHP and MySQL, so how can Faceboo...

Blocking '0000-00-00' from MySQL Date Fields

I have a database where old code likes to insert '0000-00-00' in Date and DateTime columns instead of a real date. So I have the following two questions: Is there anything that I could do on the db level to block this? I know that I can set a column to be not-null, but that does not seem to be blocking these zero values. What is the b...

MySQL error with SQL AS

Hi there, I'm receiving the following error with this page while trying to retrieve information from my database; You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM catalog_product_entity cpe inner join catalog_product_entity_varchar c...

How can SELECT HEX(CHAR(0x4E8C USING ucs2)) return '4E01' instead of '4E8C' ?

I converted a kanji column in my database to UCS-2 codes with this, it works: SELECT hex(convert('二' using ucs2)); => 0x4E8C aka &#x4E8C aka Unicode Code Point 20108 But if I want to convert my SQL results back to kanji, I get the wrong character: SELECT CHAR(0x4E8C USING ucs2); Returns 丁 which has code point 0x4E01 Inste...

How to Intentionally Create a Long-Running MySQL Query

I know this is an odd question to ask, but I'd like to find out if there is a MySQL query I can create without already having millions of rows in my database that will consume resources and run for a long time. My ultimate goal is to test my application in cases of resource contention and make sure that my methods for handling failure (...

What is the MS SQL Server capability similar to the MySQL FIELD() function?

MySQL provides a string function named FIELD() which accepts a variable number of arguments. The return value is the location of the first argument in the list of the remaining ones. In other words: FIELD('d', 'a', 'b', 'c', 'd', 'e', 'f') would return 4 since 'd' is the fourth argument following the first. This function provides t...

What happens if Drupal's user_save() fails?

I'm on Drupal 5.x and I'm trying to add new users to the site using a script that calls drupal_bootstrap(). After generating the username, email, password, and role array, I create the new user like so: $newuser = array( 'name' => $username, 'mail' => $email, 'status' => 1, 'pass' => $password, 'roles' => $roles); $user = user_save('', ...

MySQL: Indexing Table With 100+ Million Rows

Hi all. I've found myself in a bit of a predicament. I have a table used for page hit tracking with nearly 105 million rows.(!) It looks like this: CREATE TABLE `media_hits` ( `id` int(10) unsigned NOT NULL auto_increment, `media_code` char(7) NOT NULL, `day` date NOT NULL, `hits` int(10) unsigned NOT NULL default '0', PRIMARY...

HashTable to MYSQL Database

I want to throw data from a very very large hashtable in Java to MYSQL database. Is there some way i could put the data all at once or in few steps rather than iterating the whole table ...

PHP Retrieving Value from MySql Error

I have a php script that I've put together from examples on the internet. I'm not very familiar with php and I'm getting an error. I am trying to get the last post date of my Wordpress blog for my program to show when the last date that we put important information for the user on it. This is my code: <?php function lpd_pos...

PHP & MySQL Database Display multiple images

Hello All, I need help with displaying images from a MySQL database. What I have is a an Dynamic PHP/HTML table that has multiple pages with a pagination link. The table layout is: Book Title, Author, Publisher, Category and image. I can connect to database with connection script - working OK. I can see all the information for the table ...

Is an invalid DB query slower than a valid one? (MySQL)

This is kind of a weird question but... If I run this query in MySQL: SELECT something FROM table WHERE id IN (); which is obviously invalid, do I get some kind of time penalty (exception throwing, logging, something), compared to throwing a valid query? The reason I'm asking is because I just found out an app I'm maintaining (not wri...

moving tables between databases

For a bit fall cleaning, I am moving 25 tables between MySQL databases (different pieces of hardware). This is not the WHOLE database, just 25 tables out of a few hundred... These tables don't really belong in there, I won't go into why for NDA reasons. Now, this is going to break a lot of code and sql queries. What is the best way t...

MySQL - Why query with 'IN' fails?

These queries return correct results: SHOW FULL COLUMNS FROM `users` SHOW FULL COLUMNS FROM `teachers` But this one generates an error SHOW FULL COLUMNS IN ('users', 'teachers') I have tried single quote, double quote, back-quote and no quote and all fail. What am I doing wrong? The error is this: #1064 - You have an error in yo...

Rails Join Table Problem

I am working on a rails project and am having some issues with the following join: @page = Page.find(params[:id], :joins => "LEFT JOIN page_translations ON page_translations.page_id = pages.id") For some reason its only pulling back everything from the Pages table. Here is my model for Page class Page < ActiveRecord::Base has_many...

Better way to store large files in a MySQL database?

I have a PHP script that you can upload very large files with (up to 500MB), and the file's content is stored in a MySQL database. Currently I do something like this: mysql_query("INSERT INTO table VALUES('')"); $uploadedfile = fopen($_FILES['file']['tmp_name'], 'rb'); while (!feof($uploadedfile)) { $line = mysql_escape_string(fget...

php,mysql , and smarty. Confused by a "{" in social-engine platform

hi I was looking at a php code from social engine and they have something like this: header("Location:user_event.php?event_id={$event_id}&justadded=1") why id it not header("Location:user_event.php?event_id=$event_id&justadded=1") or header("Location:user_event.php?event_id=".$event_id."&justadded=1") because the value of $even...

Need to concatenate results of a subquery in a select statement

I have three tables Table1: Users Columns: User_ID (int), FirstName, LastName.... Values 1 Jane Doe 2 John Doe 3 Mike Smith Table2: User_Groups Columns: User_ID (int), Group_ID(int) Values: Row1: 1 2 Row2: 1 3 Row3: 2 1 Row4: 2 3 Row5: 3 ...

How would I globally add +1 to a table in mysql?

There was a problem with an sql server and my voting system set back people 1 day. I want to make it up to them and give them 1 point increase to make up for the loss. How would I go about doing that? I was thinking of this but I don't think it would work.. SELECT votepoints FROM vsystem where votepoints=votepoints+1 ...