mysql

MyISAM or InnoDB,for safe of data, which should i choose?

MyISAM or InnoDB,for safe of data, which should i choose? ...

String manipulation in MySql

Hi friends, I m using mysql. in one field i have inserted data like string1::string2 two string concated by :: now i want to fetch only second string , Could any body help me for this, Thanks in advance ...

Most appropriate data structure for an ordered list in an RDBMS?

I'm storing an ordered list of several million items in a MySQL database. Reasonably often, items need to be added or removed from the list; equally often, the position within the list of an item must be determined. I'd say the read/write ratio is about 50:50. Starting with a linked-list model, I read [1] and the various models discusse...

SQL ranking solution

Hello, I am implementing ranking solution for one of my tables to optimize read queries to get rid of expensive queries which use COUNT(*), LIMIT and OFFSET clause. My problem is that I don't know why position calculation are incorrect. Please look at my example to reproduce problem. CREATE TABLE `acl` ( `id` MEDIUMINT(8) UNSIGNED N...

Deleting duplicate rows from a table

I have a table in my database which has duplicate records that I want to delete. I don't want to create a new table with distinct entries for this. What I want is to delete duplicate entries from the existing table without the creation of any new table. Is there any way to do this? id action L1_name L1_data L2_name...

What is the simplest way to get all the parents of a record using the id / parent_id model in mysql/php?

I'm looking for the simplest way to recursively get all the parent elements from a database using the adjacency list / single table inheritance model (id, parent_id). My select currently looks like this: $sql = "SELECT e.id, TIME_FORMAT(e.start_time, '%H:%i') AS start_time, $title AS title, ...

Running a .sql script using MySQL with JDBC

I am starting to use MySQL with JDBC. Class.forName("com.mysql.jdbc.Driver"); conn = DriverManager.getConnection("jdbc:mysql:///x", "x", "x"); stmt = conn.createStatement(); stmt.execute( "CREATE TABLE amigos" + "("+ "id int AUTO_INCREMENT not null,"+ "nombre char(20) ...

How do you deal with saving an attribute related to an object not yet created, via AJAX?

I have an object that hasn't been created yet (so it has no ID), but the user is in the process of filling out fields to create it. For one of the fields, they create an attribute for this object, but that attribute requires the object's ID. That's where the issue is -- since the object hasn't actually been created yet (the user is in t...

how to write this sql statement

Hello, I have a rather simple question. How would I write this statement in php? $q="SELECT t1.gebruikersnaam FROM tbel_leden as t1,instellingen as t2 WHERE t2.ledenid=t1.ledenid AND t2.livetracking=1"; I know it's just supposed to be a string but the error says unexpected t_variable and php admin is not helping either. Thanks ...

Is it possible to combine Cloud Computing and MYSQL?

The main bottle neck of a web server locates usually in the database,in my case,MYSQL. More specifically,fulltext search and master-slave replication. And sphinx is a probable solution for fulltext-search,so master-slave replication is the final pain in ass. Is it possible to boost the performance significantly with the technology o...

creating keywords dynamically from mysql using php

Hi, My structure: in each category there are texts. These texts are entries of its own. So, table 'category' and table 'texts'. There are about 90 texts in every category, each text is about 300 characters. What i want to do is to make meta tags (keywords) for the categories. How to> get all relevant 'texts' and rank all words and take...

conditional on duplicate key update

I'm trying to insert a new row, but if the key already exists, I want to update the row ONLY if a certain other value is in the table is different. Is this possible in a mysql query/statement? My table consist of the following columns: hat, mittens, name, last_update hat+mittens make up the unique index (say the values for "hat" and "m...

Creating a quicker MySQL Query

I'm trying to create a faster query, right now i have large databases. My table sizes are 5 col, 530k rows, and 300 col, 4k rows (sadly i have 0 control over architecture, otherwise I wouldn't be having this silly problem with a poor db). SELECT cast( table2.foo_1 AS datetime ) as date, table1.*, table2.foo_2, foo_3, foo_4, fo...

multiple dynamically generated checkboxes in PHP/MySQL

Hi, I have a series of check boxes that are coming out of one MySQL table: <?php $result = mysql_query("SELECT * FROM strategies"); if (!$result) { die("Database query failed: " . mysql_error()); } while($row = mysql_fetch_array($result)) { $strategylist = $row['name']; $strategyname = htmlspecialchars($row['na...

Which is the best character encoding for Japanese language for DB, php, and html display?

hi my friends , i just want to know about the language transation for the Japanese, 1) Which is the best encoding for the database mysql 2) Which/how can i print that in HTML page. ? thanks in advance. ...

A reverse of Haversine formula for MySQL?

In my DB i store a center point, along with a radius (in meters). I'm looking to pass in a lat/lng, and then have the mysql values i've stored create a circle to tell me if my point i passed in is within that circle. Is there something that would allow me to do this, similar to the haversine forumla (which would assume that my point w...

Return Data and Type of mysql_fetch_array()

Consider the following 3 standard statements $queryString = "SOME SQL SELECT QUERY"; $queryResult = mysql_query($queryString); $queryArray = mysql_fetch_array($queryResult); Question is : If the result set of the query is empty, what will be the resultant datatype and value of $queryArray after all three statements are executed ? ...

MySQL DB quad-directional synchronization without master server?

I need to set up 4 MySQL servers. Each of them needs to support both reads and writes, so a master server (that accepts only writes) is out of the question. I need the data between these 4 servers to be synchronized. It does not matter to me if they have a constant connection open between themselves or if they each connect periodically. ...

how much more performant is sphinx than MySQL default fulltext search?

MySQL's default fulltext search sucks when the data volume is big. So I'm counting on sphinx to get rid of the trouble. Is there a benchmark data available that compares these two kinds of searches? ...

Should my database driver classes support replication (PHP)?

Hello, I'm currently writing a PHP application and drivers (classes) for the database engines. I was wondering if I need to write a replication support (master-slave)? I'm a bit new to this, so, what kind of things should my project or classes worry about if I want to support load balancing/replication? Oh and this is about MySQL. ...