mysql

Smart mysql query error interpreter

I am looking for an application, that would give me some more descriptive information about syntax errors in SQL queries, than: 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 (...) Finally I always find out what is wrong with my query, but it is ...

innodb_file_per_table doesn't work

Hello I am trying to use the innodb_file_per_table option of my mysql 5.0. my relevant my.cnf is: innodb_data_file_path = ibdata1:100M:autoextend innodb_file_per_table innodb_autoextend_increment = 100 but when i drop & recreate my schema & DB, i see the split files for tables, but they are too small! (they dont start fr...

Best practices for efficiently storing md5 hashes in mysql

Possible field types: BINARY(16) CHAR(32) BIGINT + BIGINT How do I decide which one to use? ...

Revision Changes - Visually showing changes.

Rollback of an article I have deleted a lot of the body of this question because I realised I should rephrase it. Here it the rephrase: How can I implement something with strike throughs? Comparing one revision update to the previous. I don't want revision or version control per se, because I can just handle that in my mySQL database...

Connecting to MySQL with --skip-ssl from Rails app

When connecting to MySQL from shell line i need to add the option --skip-ssl From my rails app I can't connecto to the MySQL server. How can I add this option to the rails app? ...

Finding the difference between two values in the same column in MySQL

Hi, I have a simple table called that contains share prices in MySQL: Table `share_prices` +----------+-------+---------------------+ | stock_id | price | date | +----------+-------+---------------------+ | 1 | 0.05 | 2010-02-24 01:00:00 | | 2 | 3.25 | 2010-02-24 01:00:00 | | 3 | 3.30 | 2...

How can I get a result from mysql_fetch_row (or mysql_fetch_array)

$sqlQuery = "SELECT * FROM allowedUsers WHERE UserID = '" . $kUserID . "'"; $result=mysql_query($sqlQuery, $db); if(!result) { echo "Error running query <br>" . mysql_error(); exit; } while($row = mysql_fetch_array($result)) { echo $row[2]; } I run the SQLQuery in phpMyAdmin and I am getting a valid result (1 row) the table...

No mapping for LONGVARCHAR in Hibernate 3.2

I am running Hibernate 3.2.0 with MySQL 5.1. After updating the group_concat_max_len in MySQL (because of a group_concat query that was exceeding the default value), I got the following exception when executing a SQLQuery with a group_concat clause: "No Dialect mapping for JDBC type: -1" -1 is the java.sql.Types value for LONGVARCHAR....

Checking for an empty field with MySQL

I've wrote a query to check for users with certain criteria, one being they have an email address. Our site will allow a user to have or not have an email address. $aUsers=$this->readToArray(' SELECT `userID` FROM `users` WHERE `userID` IN(SELECT `userID` FROM `users_indvSettings` WHERE `indvSettingID`=5 AND `optionID...

Optimisation of volatile data querying

I'm trying to solve a problem with latency on a to a mysql-5.0 db. The query itself is extremely simple: SELECT SUM(items) FROM tbl WHERE col = 'val' There's an index on col and there are not more than 10000 values to sum in the worst case (mean of count(items) for all values of col would be around 10). The table has up to 2M rows. The...

Foreign Key doesn't stop me entering data MySQL

I have a table which has one column as a foreign key joining to another table. It's a cricket question where I have a table called Fixtures and another called Inning. Inning table has a FixtureId column relates to the Fixture table. I would expect that If i do a insert on the inning table using a FixtureId that doesn't relate to a F...

sub query mysql

If I have a table like this: yr subject 1960 Physics 1960 Chemistry 1961 Physics 1962 Chemistry I want all the years when the subject is Physics and not chemistry If I try this , it does not give me correct result. select yr from table where subject = "Physics" and yr NOT IN (select yr from table where subje...

Illegal mix of collations in mySQL

I need to transfer a column from one table to another. The source table has a different collation than the target table (latin1_general_ci and latin1_swedish_ci). I use UPDATE target LEFT JOIN source ON target.artnr = source.artnr SET target.barcode = source.barcode I get an "illegal mix of collations". What is a quick fix to ge...

accessing mysql through asp.net

i have mysql running locally, and i would like to access it using asp.net through a browser. can someone recommend me a simple tutorial on how to do this? ...

select * from table where datetime in month (without breaking index)

I have a bunch of timestamped rows (using the 'datetime' data type) I want to select all the rows that have a timestamp that is within a particular month. The column is indexed so I can't do MONTH(timestamp) = 3 because that'll make this index unuseable. If I have year and month variables (in perl), is there a horrific bit of SQL I ca...

MYSQL UPDATE - 1 DAY off DATE field?

Hello, I have a table which stores featured from and to for objects. I would like to unfeature an item via ajax. The way I have decided todo that is to set any featured rows for an object called to -1 day from now so its no longer featured. However my query isn't working. UPDATE `Movie_Featured` SET `to` = DATE_SUB(CURDATE(), INTERVA...

How can I get insert query to work with two if(isset statements?

On a users profile, there is a comment box that enables other users to post comments on their profile. I am now working on a dynamic comment area that has a changing text box depending on if A. you are looking at your own profile B. looking at someone elses profile C. not signed in at all. I am trying to implement "updates" now when you...

is it possible to store the rank of ordered items rather then their score?

For example I have this query which orders val2 according to their item with max count. INSERT INTO table d (val1, val2 ,cnt) SELECT val1, val2 , max(cnt) as cnt FROM table2 WHERE val1 =x GROUP BY val2 ORDER BY max(cnt) DESC LIMIT 10; Instead I want to rank the results so cnt isnt going to be a random number but 1 if its respective v...

Why can't tinyint store more than the number 255 in MySQL?

If TINYINT can store three characters, for example, why can't it store up to the number 999? ...

MySQL: How can I condense this verbose query?

Here is my schema: Suppliers(sid: integer, sname: string, address string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real) Primary keys in bold. Here is the MySQL query I'm working with: -- Find the sids of suppliers who supply every red part or supply every green part. -- this isn't...