mysql

MySQL records count with condition

I need to get records count of table «posts» where votes>=5 to create pagination. tables: table «posts»: user_id, post_n, visibility, type visibility values: 0, 1, 2; type values: 'text', 'photo' … (it`s enum field, have 6 values) table «votes»: vote_n, post_n, voter_id, vote vote values: -1 or 1 query: SELECT post_n, (SELECT SUM...

MySQL Select Multiple VALUES

Totally out of ideas here, could be needing a simple solution. Basically my desired query is : SELECT * FROM table WHERE id = 3,4 I want to select only the row which has ID 3 and 4, or maybe name "andy" and "paul" Thank you very much for the answer ...

Mysql Postgresql cast

I have a column (varchar in mysql and a character varying in postgresql). I need to apply sum on the column and I need a cast syntax that works for both. The db structure is old and has both int and varchar values. I can't change that. ...

inserting data into two tables?

im using mysql, these are two tables i have: posts {id, user_id, post, date} post_tags {id, tag, post_id(references id in post), user_id} what im trying to do is if the post has a #tag , i insert the intial post in the POSTS table, and the data in the post_tags table, how could i do that simlateanously? P.S. i already know how to che...

Over 3.000 transactions in CakePHP. How?

We are doing an import of Magento-products into a CakePHP environment over SOAP. We have like 3.000 products and of course we want to keep the database clean of duplicate entrys. We use InnoDB as product-databse in CakePHP. We had different approaches: We set the validate var on the product model and want the product-id to be unique....

How to get Mario Kart Wii scoreboard points after race into database

I don't think this is even possible, but maybe I'm missing something. A group of us play Mario Kart Wii in the office. We don't play online, just a couple races. We often have tournaments where we play multiple sets of races over a couple of weeks and then combine the scores at the end. Instead of writing the final points down after ...

MySQL PHP Pagination

Is it possible to create pagination without getting all elements of table? But with pages in GET like /1 /666… ...

calculating the number of days using strtotime returns wrong result

I have two dates stored in a mysql database (Type = date). For example - Date 1 = 2010-09-20 Date 2 = 2010-10-20 I want to calculate the number of days between these two dates. So have tried this - $number_days = (strtotime($date2) - strtotime($date1) / (60 * 60 * 24)); But this returns 49 How so? -------------------------------...

drupal with more than 100000 nodes, performance increase to vey high

I have a drupal site with more than 100000 nodes and counting. I want to know, how can I increase the site performance dramatically. There are certain days when traffic is high and the site becomes really slow. The site also uses views heavily and the frontpage is panels based. With the same resources I have now, what can I do to in...

Mysql Complex Where Clause

I really surprised when I tried below code in MySQL: SELECT * FROM table WHERE (key='free_shipping' and value='yes') AND (key='price' and value='5') It doesn't work. I need to get product that is both free_shipping is 'yes' AND price equal '5' at the same time. How can I create this query properly? Table Structure: contents: (TABLE...

"disable" some MySql records so they are not returned when searching?

I have a mysql database which I support using phpMyAdmin. The website this is for is a classifieds website. The issue here is that whenever a new classified is posted (and inserted into mysql database), I need to first review it manually. My question is, is there anyway to tell mysql that "this record is inactive, so don't return it"?...

find the space occupied by records in mysql

I want to find the space occupied by the records in database. I have 2000 records. I need to find how much space occupied by empid 4 in the database in mySQL. Please let me know the query in mySQL. ...

product website with php and mysql.

I want to create a product website with 80 pages. Its a product showcase and I have 70 products with its images and specifications. If its in html , I have to create 70 pages, i would like to do it in php and my sql. What I would like to do is , I will create a template for the product page.On click of each product name , the details of...

Backup a mysql database and download as a file

How to backup the mysql database and download it as a .sql file by using PHP Codes ...

mysql content fields idea :)

I try new table structure for our new eccomemrce website like Wordpress tables. But I am not sure whether it's really good idea for performance. We've just 2 tables for products and other contents (such us pages, attachments, or even orders). Their ordinary fields kept first table (such as ID, title,date), but their special fields kept ...

How to get records for the most recent complete 13 weeks?

I have a MySQL database table, with a unix timestamp field. I am wondering how to get the most recent complete 13 weeks? Update But I need to opt out the current week. So I need the last complete(that ended in past or today) 13 weeks. ...

MySQL dump .sql script and import to an apache derby

So presumably mysqldump can export to ansi compatible format so that you can import to other vendors' databases. However trying to import to an apache derby I face all this syntax errors. Thought I try some regex and fix things but it seems that there are more than a couple. Is there something I'm missing about mysqldump? Tried ddlutil...

MySQL: Large table splitting

I have a huge table in a database and I want to split that into several parts physically, maintaining the database scheme. For example, the table name is TableName and has 2 000 000 rows. I would like to split that table into four parts, but I want to work in the same way with the table, so select [Column List] from TableName where [F...

Boolean vs tinyint(1) for boolean values in MySQL

Hi All, What column type is best to use in a MySQL database for boolean values? I use boolean but my colleague uses tinyint(1). ...

When is innodb_lock_wait_timeout ignored ?

Related to my other questions, I'm having a weird case of the classic deadlock exception: Caused by: java.sql.BatchUpdateException: Deadlock found when trying to get lock; try restarting transaction. blablalbla... The code is identified and indeed, it's possible to get a deadlock. The thing is that I'm getting the exception immediatly. ...