mysql

How to do fast counting on large tables?

I have large MySQL tables with hundreds of thousands of rows. I need to write a query on a customers table which gets the count of when customers will be available to contact again. eg. SELECT 'This week', COUNT(*) FROM customers WHERE sales_person_id = 1 AND DATEDIFF(NOW(), available_date) < 7 UNION SELECT 'Next week', COUNT(*) ...

Best way to store span on time in a MySQL database?

I'd like to store an amount of time for something in a mysql database,for the length of time something took, such as 2 hours, 5 minutes, 10 seconds. accuracy down to the second is preferred, but not required. What's the best way to go about doing this? ...

Check Box value not being passed on to database

Hello, I am using an MySQL table with the following structure: `login` ( `loginid` int(11) unsigned NOT NULL auto_increment, `username` varchar(30) NOT NULL, `password` varchar(50) NOT NULL, `email` varchar(255) NOT NULL, `actcode` varchar(45) NOT NULL, `disabled` tinyint(1) NOT NULL default '0', `activated` tinyint(1) NO...

PHP implode array to generate mysql IN criteria

I have a function like the following: public function foo ($cities = array('anaheim', 'baker', 'colfax') ) { $db = global instance of Zend_Db_Adapter_Pdo_Mysql... $query = 'SELECT name FROM user WHERE city IN ('.implode(',',$cities).')'; $result = $db->fetchAll( $query ); } This works out fine until someone passes $cities...

JQuery. Array of connected sortable lists. Save to Mysql. Desperate

Hello, I have been intensively looking for an answer for a week. There are a lot of examples out there, how to save results, when having fixed number of lists. My task is: I have one 'ul' list, full of items (with id from 1 upwards) queried from MySQL. And I have several other EMPTY 'ul' lists (with id from 1 upwards) also queried fr...

JPA: how do I persist a String into a database field, type MYSQL Text

The requirement is that the user can write an article, therefore I choose type Text for the content field inside mysql database. How can I convert Java String into MySQL Text Here you go Jim Tough @Entity public class Article implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(stra...

PHP - How to check if Curl actually post/send request?

Hey, I basically created a script using Curl and PHP that sends data to the website e.g. host, port and time. Then it submits the data. How would I know if the Curl/PHP actually sent those data to the web pages? $fullcurl = "?host=".$host."&time=".$time."; Any ways to see if they actually sent the data to those URLs on My MYSQL? ...

Keeping id's unique Client Side and Server Side

Hi all, i am scrubbing my head now for hours to solve thw following situation: Several Html Forms on a webpage are identified by an id. Users can create forms on the clients side themselves and fill in data. How can I guarantee that the id of the form the user generates is unique and that there doesnt occure any collision in the saving ...

merge tables and query

I have this tables in my mysql schema: posts: --------------------------------------------- id|type | userid | title | msg | time_added users: ------------------ userid | username How can I show only 6 entries where: type is audio or video and only for a certain username? ...

Automatically sharding MySQL?

Right now, I'm dealing with a TON (trust me) of data that needs to be available in real-time for fast reads and writes to customers. The backend storage system that we're using is Oracle, but we'd like to replace our big, beefy machines with a leaner system. For various reasons, we can't use Cassandra, and we're testing (but I'm scared...

LAMP UTF-8 saving incorrectly to MySQL Database

I've converted my database from Latin 1 to UTF8, and using phpPMyAdmin you can enter data and display it correctly. However viewing in the pages I've developed in PHP and editing it using my simple CMS saves characters that must be incorrectly coded. I've spent a few hours researching and eventually came up with this code snippet: mysq...

Dealing with asterisks in Sphinx results

I'm using Sphinx to search MySQL. One of the results Sphinx returns for a search is M*A*S*H, as in the hit television show. The problem I'm facing is that M*A*S*H is returned for nearly any query made with Sphinx. I'm guessing this is due to the asterisks. If not, then what could the problem be? If the asterisks are causing my probl...

ruby on rails + xampp + mysql (windows 7)

I am trying to use the mysql package included in xampp with ruby on rails on windows 7, but cannot seem to get them to work together. I have rails 3.0.0 and xampp 1.7.3 rails works with sqlite within xampp just fine, but when attempting to use mysql via "rails new project -d mysql; cd project; bundle install" I get the following: In...

how do i get mysql rows from 24-48 hours ago?

I have a mysql table with a datetime column. I want to fetch rows which are older than 24 hours but younger than 48 hours. Ive gone through the date time function not quite sure how to approach this or what to do in general. ...

Which tech to use for a server-side repository of files for a desktop C++ application to pull from?

I'm writing a cross-platform application in C++ (with wxWidgets lib), which currently references a server-side MySQL database which contains information (including target file name) of a very large number of files. Currently I am doing this by opening a direct SQL connection with each client (with thousands of users, this is not very eff...

MySQL joins for friend feed

Hi everyone, I'm currently logging all actions of users and want to display their actions for the people following them to see - kind of like Facebook does it for friends. I'm logging all these actions in a table with the following structure: id - PK userid - id of the user whose action gets logged actiondate - when the action happe...

Updating users table from complex SQL query, users.id not recognised?

So the other day, I asked this question about how to combine three complex queries and found a way to do it. Now I'm trying to use those queries to update a field in the users table and can't find a way to make it work. Here's the query: update users set field_sum =( select sum(field_sum) from ( select sum(field_one) as fi...

MYSQL - Join most recent matching record from one table to another

Hi, I have two tables that look like this: Table: cases id name status case_no Table: notes id case_id note_date notes I'd like to be able to create a query that grabs the data from the cases table and only the most recent entry from the notes table for each row in the cases table. So far I'm having no luck at all. Any pointe...

MySQL greatest-n-per-group trouble

Hey everyone. I believe this is a 'greatest-n-per-group' question but even after looking at several questions on StackOverflow, I'm unsure how to apply this to my situation... I'm using a MySQL database and have a basic blog-type system set up about Computer Applications... The tables look like this: POSTS post_id post_created post_t...

how can i show specific data based on currently selected option in a dropdown list?

little background: currently putting together a website that is selling products, many of which come in various sizes, with respectively different prices. I have the database set up to handle all of this, and I know well enough how to write the PHP code to query said database to get any product in a specific size (with all it's related...