mysql

How to store the php result of md5("test", true) in a BINARY field of a MySQL MyISAM table

How can I store the result of: $store = md5("test", true); mysql_query(...) in a mysql db with a string query? ...

MySQL Query: Select an int field multiple times based on range the numbers fall into

I have an int field in my table scores. It can be a number between 0 and 100. There are over a 1000 rows in that table. I want to select the number of rows that fall between ranges 0-25, 26-50, 51-75 and 76-100. So basically, if this is my scores table score (int) ------------ 10 20 12 56 43 90 87 The output of the query shoul...

Getting the exception like "Cannot convert value '0000-00-00 00:00:00' from column 12 to TIMESTAMP"

Previously the column Data type is Date now I am changed to Timestamp Now if I tried to run the program am getting them exception java.sql.SQLException: Cannot convert value '0000-00-00 00:00:00' from column 12 to TIMESTAMP. at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1298) at com.mysql.jdbc.ByteArrayRow.getTi...

Loading behaviour of EF v1?

Hello, another Entity Framework (ADO.NET) question from me. I'm using EF1 (no choice there) and have a MySQL database as a backend. A simple question I can't really find a satisfying answer for: What exactly do I have to do for loading? IE., when I have an entity and want to enumerate through its children, say I have the Entity "Group"...

(my)SQL: Select 20 latest entries in logfile from unique persons

hi, I have a logfile which logs the insert/delete/updates from all kinds of tables. I would like to get an overview of for example the last 20 people which records where updated, ordered by the last update datetime DESC What I have now is: SELECT DISTINCT logfile.idvalue, DATE_FORMAT(logfile.logDateTime,'%d-%m-%Y %H:%i') AS thedateti...

Using MySQL's IN statement in Java

I have to find out if there are entries in a table that also exist in a list I have in Java. The logical solution would be "SELECT column FROM table WHERE column IN (?)" and then set ? to the array I have in Java, but setArray asks for a java.sql.Array and I'm not really sure how to obtain one and if it really is what I am looking for. ...

MySQL: Most efficient data type to store long notes?

I was wanting to create a personal note database, to store notes in HTML or text that are quite long. What would be the difference between VARCHAR and TEXT fields, which one would be more efficient to use? I think VARCHAR's max is 65535 characters, I can't wrap my head around if I'll contain anything larger than that though. I wonder if...

Effectively (in terms of performance) store and use set values in MySQL

I need to store set value in MySQL column. I completely like the build-in SET type, but it seems that FIND_IN_SET() function requires table scan which is bad. It seems that SET uses binary values under the hood. If I use binary value to represent a set, for example for a set of four elements it could be something like this: 0100 0101 0...

How do create a HTML scraper in PHP and get it working properly?

Please HELP! :( I am looking to develop a PHP Script to do the following: Scrap a remote HTML page and extract selected data (e.g. particular table/div) Use extracted data and save it into a Database (e.g. MySql) Anyone can help out? Thanks and appreciate your soonest feedback. ...

MySql table design : Use lots of rows or store the information formatted in one text field per row?

I am trying to discover the best way to design my database to organize information related to events. I have an events table which contains all the information about the event such as, a unique id, title of the event, venue etc. Now each event can have multiple ticket types and the number and type of tickets will change with each event...

If else Update Category echo display image

HI I Need to display an image when Category Update and that image display upto 3 days i use this but not work $todaytime = time(); $timestamp = $show_wallpaper['timestamp']; $timediffirence = "360000"; $minus = $todaytime - $timestamp; if ($timediffirence > $minus) { $new =...

BIT(1) vs ENUM('unknown', 'male', 'female') in MySQL

In performance terms, what will be faster, use a BIT(1) NULL (null = unknown, 0 = male, 1 = female) or ENUM('unknown', 'male', 'female') NOT NULL DEFAULT 'unknown' in MySQL MyISAM? Or this is considered micro-optimization? [EDIT] I think I'm going to use ENUM('male', 'female') DEFAULT NULL ...

constructing a query for the following table

can anyone generate a query for me. Lets say i have a table sales(saleID, date_of_sales, customerID, itemID, saleprice) date_of_sales is the datetime field which stores the time of the sale. customerID is self exlpaining tells to whom item was sold. itemID is ID of the item sold. saleprice is the price that the item was sold. I ...

Help getting started with OO PHP & MySQL

Hi, I have been writing a lot of code for work in PHP/MySQL. So far it has all been procedural making use of functions for functionality occuring multiple times/places. Starting to find some of the site hard to manage - time to go OO. I want to learn about MVC with object oriented PHP & MySQL. I have some experience in Java and MVC but...

Constant MySQL Connection or Connect when needed.

I am building a little daemon which periodically (every 30 seconds) checks for new data and enters it in a local MySQL Database. I was just wondering whether it was better to create a connection to the database when the application launches and always use that connection throughout the application until it is closed, or if it should onl...

how to retrieve table names in a mysql database?

I have a sql database and am wondering what command you use to just get a list of the table names within that database. ...

Using Mysql and sql server from python

I need to write a python application with use both of the mysql and sql server is there a general python module or library that can access both mysql and sql server as DBI with perl or should i use 2 libraries and if yes which libraries do you recommend . ...

How should this MySQL Query look like?

I have a table with the following design: ID OPT_1 OPT_2 OPT_3 A_ID 1 3 4 3 1 2 5 2 1 1 3 1 2 2 1 I want to select all OPT's for A_ID 1, but when I run the query, I don't know the A_ID, I only know the OPT's. So how can I insert a variable to get ...

Return parent records with child records equaling specific values AND where total set of child records for a given parent equal a specific value

Currently I have a query that returns parent data for parent records that have a subset of child table records equaling certain values. However, I want to narrow it to only return those parent records with children having certain values, but where those are the only child records belonging to given parent or where the number of child re...

Zend Framework Mysql Update

I need to execute this simple mysql query in Zend; "UPDATE `table` SET `field`='field'+1 WHERE `field`>'" . $var . "'" How can I do this with Zend update; $this->update($data, $where); But we hasn't data, we have only where. ...