mysql

Practical MySQL tips and literature for more advanced use?

This is yet another MySQL literature question. I asked for some MySQL / DBA literature earlier that day, but most of the suggestions were beginners guides that were more or less like a commented documentation with examples. Of course I can still learn a lot from these books / tutorials, too - but it´s NOT what I ask for here. Rather I´...

mysql error with a large union: Incorrect key file for table '#sql_24b3_61.MYI'; try to repair it

hi.. I am doing a sitewide - query across a large wordpress MU installation. i am getting this error: Incorrect key file for table '#sql_24b3_61.MYI'; try to repair it The table signified, sql_24b3_61 is not part of my db. Also, the query is very large as it queries across many tables. It seems to be some configuration setting? ...

How to add 2 temporary tables together.

If I am creating temporary tables, that have 2 columns. id and score. I want to to add them together. The way I want to add them is if they each contain the same id then I do not want to duplicate the id but instead add the scores together. if I have 2 temp tables called t1 and t2 and t1 had: id 3 score 4 id 6 score 7 and t2 had: ...

Which database (DBMS) can best handle large tables?

I also have a very large table in SQL Server (2008 R2 Developer Edition) that is having some performance problems. I was wondering if another DBMS would be better for handling large tables. I'm mainly only considering the following systems: SQL Server 2008, MySQL, and PostgreSQL 9.0. Or, as the referenced question above eludes to, is ...

sql syntax, if exist

Hi, why i get error: #1064 - 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 'IF EXISTS(SELECT id FROM mytable WHERE id = '1')' at line 1 query: IF EXISTS(SELECT id FROM mytable WHERE id = '1') Thanks ...

Sort List After Last Name, then First Name?

I'm planning on building a mySQL table that requires a student's name which looks like this: Last Name + Father's First Name Initials + First Name Example: Beavers L. Scott James (father has one first name, son has two first names) Beavers L. D. Scott (father has two first names) Instead of requiring to fill in 3 input fields, I o...

Using RMysql's dbGetQuery in R, how do i coerce string data type on the result set?

RMysql's dbGetQuery converts BigInt to numeric types. This alters some of the values. How can I read the BigInt fields as strings instead of numeric? ...

mysql: selecting rows if a number is in a list field (ie. userIDs = "1,2,3", select * from table where 1 in userIDs)

i store lists of ids inside fields (by list i mean val1,val2,val3,...), and i want to select rows from a table where the field has valX in the list. i thought this would work, but apparently not :( SELECT * FROM userbulletins WHERE 25 IN `currentMessages` OR 25 IN `removedMessages` OR 25 IN `readMessages` currentMessag...

get us, uk in one table, cn and jp in the other, but not br in both

in countrylanguage, countrycode | language US | English BR | Portuguese UK | English in countryname, countrycode | name CN | China BR | Brazil JP | Japan "an inner join produces results by selecting combinations of matching rows from the joined tables. However, i...

MySQL: How to add a column if it doesn't already exist?

I want to add a column to a table, but I don't want it to fail if it has already been added to the table. How can I achieve this? # Add column fails if it already exists ALTER TABLE `TableName` ADD `ColumnName` int(1) NOT NULL default '0'; ...

SQL / Wordpress - query for removing a comment field

Hi Does anyone know how can I replace the "comment_author_url" field from all comments by running a SQL query? for example if this field is http://google.com to replace it with "" (empty string) ...

Getting results from one table, grouped by user and date, joined on the user's name and account info from another table?

Let's say I have three tables (with the columns in each): USERS: id, name, account_id ACCOUNTS: id, name EVENTS: event_id, user_id, date And I want to get the total count of events from EVENTS for each user, within a date range, along with the user's name and account name. I can use GROUP BY to group the results by user_id, but how ...

How can I transfer data between 2 MySQL databases ?

I want to do that using a code and not using a tool like "MySQL Migration Toolkit". The easiest way I know is to open a connection (using MySQL connectors) to DB1 and read its data. Open connection to DB2 and write the data to it. Is there a better/easiest way ? ...

Exploding a string and looping through an array in MySQL outside another language

I'm creating a MySQL UDF (User Defined Function) to capitalise the first letter of every word. This is what I have so far: drop function if exists upperfirst; create function upperfirst (s varchar(255)) returns varchar(255) deterministic return concat(ucase(mid(lower(s),1,1)),mid(lower(s),2)); This is working pretty well so ...

What's wrong with this code (mysqli) ?

Not working: $link = mysqli_connect("localhost", "********", "*******", "*******"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $cmp = 126; if (($stmt = mysqli_prepare($link, "SELECT datalock FROM sys_tenancy WHERE id=?"))) { echo mysqli_stmt_bind_param($stmt, "i", $cmp) ?...

Rating System Query

I've built a rating system for movies in MySQL, however the concern is that when my query sums up all the ratings and divides it, it might have to sum up millions and millions of records. One solution I thought of was to basically cache the rating in memcached and only do the rating operation for items which are not used a lot. However ...

Django unable to find MySQLdb python module

Installed Django from source (python setup.py install and such), installed MySQLdb from source (python setup.py build, python setup.py install). Using Python 2.4 which came installed on the OS (CentOS 5.5). Getting the following error message after launching the server: Error loading MySQLdb module: No module named MySQLdb The pythonpa...

Auto-complete search box, selecting multiple values from results

I'm creating my own recipe box using php/mysql and one part I'm stuck on is actually creating the recipes, specifically selecting the ingredients. What I wanted to do instead is have a auto-complete search box where I can type out names of the ingredients, have the results drop down right below, and click the ones I'm looking for. After...

How to include ' in the input form ?

Hi, I just realize that in my forms I couldn't save name like O'Brian (It would saved as O only and 'Brian will be truncated). I'm using grails 1.2.2 with mysql. is there simple ways to allow ' to be inserted into db ? rather than modify each form and put html replacement for that char ? ...

php/mysql newbie question

excuse the title but as im not an expericened programmer i dont know how to describe this problem So the problem. I have 2 topics in my topics table. When im on thread 2 it correclty prints a thread to thread 1 but when im on thread 1 it doesnt print the link to thread 2. Whats wrong? $prev_thread = mysql_query("SELECT MAX(id) as pre...